-
Notifications
You must be signed in to change notification settings - Fork 62
/
none_client.go
57 lines (43 loc) · 1.64 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
55
56
57
package nilrouting
import (
"context"
"errors"
repo "github.com/ipfs/go-ipfs/repo"
p2phost "gx/ipfs/QmPsRtodRuBUir32nz5v4zuSBTSszrR1d3fA6Ahb6eaejj/go-libp2p-host"
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
routing "gx/ipfs/QmbkGVaN9W6RYJK4Ws5FvMKXKDqdRQ5snhtaa92qP6L8eU/go-libp2p-routing"
cid "gx/ipfs/QmcTcsTvfaeEBRFo1TkFgT8sRmgi1n1LTZpecfVP8fzpGD/go-cid"
pstore "gx/ipfs/QmeXj9VAjmYQZxpmVz7VzccbJrpmr8qkCDSjfVNsPTWTYU/go-libp2p-peerstore"
peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
)
var log = logging.Logger("mockrouter")
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) 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{}