-
Notifications
You must be signed in to change notification settings - Fork 64
/
disabledprovider.go
51 lines (39 loc) · 1.79 KB
/
disabledprovider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package indexprovider
import (
"context"
"fmt"
"github.com/ipfs/go-cid"
"github.com/ipni/index-provider"
"github.com/ipni/index-provider/metadata"
"github.com/ipni/storetheindex/api/v0/ingest/schema"
"github.com/libp2p/go-libp2p/core/peer"
)
type DisabledIndexProvider struct {
}
var _ provider.Interface = (*DisabledIndexProvider)(nil)
func NewDisabledIndexProvider() *DisabledIndexProvider {
return &DisabledIndexProvider{}
}
func (d DisabledIndexProvider) PublishLocal(ctx context.Context, advertisement schema.Advertisement) (cid.Cid, error) {
return cid.Undef, fmt.Errorf("could not publish locally: index provider disabled")
}
func (d DisabledIndexProvider) Publish(ctx context.Context, advertisement schema.Advertisement) (cid.Cid, error) {
return cid.Undef, fmt.Errorf("could not publish: index provider disabled")
}
func (d DisabledIndexProvider) RegisterMultihashLister(lister provider.MultihashLister) {
}
func (d DisabledIndexProvider) NotifyPut(ctx context.Context, provider *peer.AddrInfo, contextID []byte, md metadata.Metadata) (cid.Cid, error) {
return cid.Undef, fmt.Errorf("could not notify put: index provider disabled")
}
func (d DisabledIndexProvider) NotifyRemove(ctx context.Context, providerID peer.ID, contextID []byte) (cid.Cid, error) {
return cid.Undef, fmt.Errorf("could not notify remove: index provider disabled")
}
func (d DisabledIndexProvider) GetAdv(ctx context.Context, cid cid.Cid) (*schema.Advertisement, error) {
return nil, fmt.Errorf("could not get advertisement: index provider disabled")
}
func (d DisabledIndexProvider) GetLatestAdv(ctx context.Context) (cid.Cid, *schema.Advertisement, error) {
return cid.Undef, nil, fmt.Errorf("could not get latest advertisement: index provider disabled")
}
func (d DisabledIndexProvider) Shutdown() error {
return nil
}