@cryptotaxi247 / kubo / commits / 953d7d467

Doc: golint-ify routing module

License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>

Hector Sanjuan committed Feb 9, 2018 at 13:10 UTC 953d7d4672f8db55e9a96993e5d3e6bfbc98ae21
3 files changed +18 -7
routing/mock/interface.go
+7 -5
@@ -1,17 +1,17 @@
1 -// Package mock provides a virtual routing server. To use it, create a virtual
2 -// routing server and use the Client() method to get a routing client
3 -// (IpfsRouting). The server quacks like a DHT but is really a local in-memory
4 -// hash table.
1 +// Package mockrouting provides a virtual routing server. To use it,
2 +// create a virtual routing server and use the Client() method to get a
3 +// routing client (IpfsRouting). The server quacks like a DHT but is
4 +// really a local in-memory hash table.
5 package mockrouting
6
7 import (
8 "context"
9
10 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
11 - "gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
11
12 ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
13 routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing"
14 + "gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
15 peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
16 )
17
@@ -42,6 +42,8 @@ func NewServerWithDelay(conf DelayConfig) Server {
42 }
43 }
44
45 +// DelayConfig can be used to configured the fake delays of a mock server.
46 +// Use with NewServerWithDelay().
47 type DelayConfig struct {
48 // ValueVisibility is the time it takes for a value to be visible in the network
49 // FIXME there _must_ be a better term for this
routing/none/none_client.go
+4 -2
@@ -1,3 +1,4 @@
1 +// Package nilrouting implements a routing client that does nothing.
2 package nilrouting
3
4 import (
@@ -21,11 +22,11 @@ func (c *nilclient) PutValue(_ context.Context, _ string, _ []byte) error {
22 }
23
24 func (c *nilclient) GetValue(_ context.Context, _ string) ([]byte, error) {
24 - return nil, errors.New("Tried GetValue from nil routing.")
25 + return nil, errors.New("tried GetValue from nil routing")
26 }
27
28 func (c *nilclient) GetValues(_ context.Context, _ string, _ int) ([]routing.RecvdVal, error) {
28 - return nil, errors.New("Tried GetValues from nil routing.")
29 + return nil, errors.New("tried GetValues from nil routing")
30 }
31
32 func (c *nilclient) FindPeer(_ context.Context, _ peer.ID) (pstore.PeerInfo, error) {
@@ -46,6 +47,7 @@ func (c *nilclient) Bootstrap(_ context.Context) error {
47 return nil
48 }
49
50 +// ConstructNilRouting creates an IpfsRouting client which does nothing.
51 func ConstructNilRouting(_ context.Context, _ p2phost.Host, _ repo.Datastore) (routing.IpfsRouting, error) {
52 return &nilclient{}, nil
53 }
routing/offline/offline.go
+7
@@ -1,3 +1,5 @@
1 +// Package offline implements IpfsRouting with a client which
2 +// is only able to perform offline operations.
3 package offline
4
5 import (
@@ -18,8 +20,13 @@ import (
20 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
21 )
22
23 +// ErrOffline is returned when trying to perform operations that
24 +// require connectivity.
25 var ErrOffline = errors.New("routing system in offline mode")
26
27 +// NewOfflineRouter returns an IpfsRouting implementation which only performs
28 +// offline operations. It allows to Put and Get signed dht
29 +// records to and from the local datastore.
30 func NewOfflineRouter(dstore ds.Datastore, privkey ci.PrivKey) routing.IpfsRouting {
31 return &offlineRouting{
32 datastore: dstore,