forked from ipfs/kubo
/
none_client.go
54 lines (41 loc) · 1.54 KB
/
none_client.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
52
53
54
package nilrouting
import (
"context"
"errors"
repo "github.com/ipfs/go-ipfs/repo"
routing "gx/ipfs/QmNdaQ8itUU9jEZUwTsG4gHMaPmRfi6FEe89QjQAFbep3M/go-libp2p-routing"
p2phost "gx/ipfs/QmUywuGNZoUKV8B9iyvup9bPkLiMrhTsyVMkeSXW5VxAfC/go-libp2p-host"
pstore "gx/ipfs/QmXZSd1qR5BxZkPyuwfT5jpqQFScZccoZvDneXsKzCNHWX/go-libp2p-peerstore"
cid "gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid"
peer "gx/ipfs/QmdS9KpbDyPrieswibZhkod1oXqRwZJrUPzxCofAMWpFGq/go-libp2p-peer"
)
type nilclient struct {
}
func (c *nilclient) PutValue(_ context.Context, _ string, _ []byte) error {
return nil
}
func (c *nilclient) GetValue(_ context.Context, _ string) ([]byte, error) {
return nil, errors.New("Tried GetValue from nil routing.")
}
func (c *nilclient) GetValues(_ context.Context, _ string, _ int) ([]routing.RecvdVal, error) {
return nil, errors.New("Tried GetValues from nil routing.")
}
func (c *nilclient) FindPeer(_ context.Context, _ peer.ID) (pstore.PeerInfo, error) {
return pstore.PeerInfo{}, nil
}
func (c *nilclient) FindProvidersAsync(_ context.Context, _ *cid.Cid, _ int) <-chan pstore.PeerInfo {
out := make(chan pstore.PeerInfo)
defer close(out)
return out
}
func (c *nilclient) Provide(_ context.Context, _ *cid.Cid, _ bool) error {
return nil
}
func (c *nilclient) Bootstrap(_ context.Context) error {
return nil
}
func ConstructNilRouting(_ context.Context, _ p2phost.Host, _ repo.Datastore) (routing.IpfsRouting, error) {
return &nilclient{}, nil
}
// ensure nilclient satisfies interface
var _ routing.IpfsRouting = &nilclient{}