Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
953d7d46
Commit
953d7d46
authored
Feb 09, 2018
by
Hector Sanjuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc: golint-ify routing module
License: MIT Signed-off-by:
Hector Sanjuan
<
hector@protocol.ai
>
parent
25eeb1e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
routing/mock/interface.go
routing/mock/interface.go
+7
-5
routing/none/none_client.go
routing/none/none_client.go
+4
-2
routing/offline/offline.go
routing/offline/offline.go
+7
-0
No files found.
routing/mock/interface.go
View file @
953d7d46
// Package mock provides a virtual routing server. To use it,
create a virtual
// routing server and use the Client() method to get a
routing client
// (IpfsRouting). The server quacks like a DHT but is
really a local in-memory
// hash table.
// Package mock
routing
provides a virtual routing server. To use it,
//
create a virtual
routing server and use the Client() method to get a
//
routing client
(IpfsRouting). The server quacks like a DHT but is
//
really a local in-memory
hash table.
package
mockrouting
import
(
"context"
delay
"github.com/ipfs/go-ipfs/thirdparty/delay"
"gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
ds
"gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
routing
"gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing"
"gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
peer
"gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
)
...
...
@@ -42,6 +42,8 @@ func NewServerWithDelay(conf DelayConfig) Server {
}
}
// DelayConfig can be used to configured the fake delays of a mock server.
// Use with NewServerWithDelay().
type
DelayConfig
struct
{
// ValueVisibility is the time it takes for a value to be visible in the network
// FIXME there _must_ be a better term for this
...
...
routing/none/none_client.go
View file @
953d7d46
// Package nilrouting implements a routing client that does nothing.
package
nilrouting
import
(
...
...
@@ -21,11 +22,11 @@ func (c *nilclient) PutValue(_ context.Context, _ string, _ []byte) error {
}
func
(
c
*
nilclient
)
GetValue
(
_
context
.
Context
,
_
string
)
([]
byte
,
error
)
{
return
nil
,
errors
.
New
(
"
T
ried GetValue from nil routing
.
"
)
return
nil
,
errors
.
New
(
"
t
ried GetValue from nil routing"
)
}
func
(
c
*
nilclient
)
GetValues
(
_
context
.
Context
,
_
string
,
_
int
)
([]
routing
.
RecvdVal
,
error
)
{
return
nil
,
errors
.
New
(
"
T
ried GetValues from nil routing
.
"
)
return
nil
,
errors
.
New
(
"
t
ried GetValues from nil routing"
)
}
func
(
c
*
nilclient
)
FindPeer
(
_
context
.
Context
,
_
peer
.
ID
)
(
pstore
.
PeerInfo
,
error
)
{
...
...
@@ -46,6 +47,7 @@ func (c *nilclient) Bootstrap(_ context.Context) error {
return
nil
}
// ConstructNilRouting creates an IpfsRouting client which does nothing.
func
ConstructNilRouting
(
_
context
.
Context
,
_
p2phost
.
Host
,
_
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
return
&
nilclient
{},
nil
}
...
...
routing/offline/offline.go
View file @
953d7d46
// Package offline implements IpfsRouting with a client which
// is only able to perform offline operations.
package
offline
import
(
...
...
@@ -18,8 +20,13 @@ import (
cid
"gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
)
// ErrOffline is returned when trying to perform operations that
// require connectivity.
var
ErrOffline
=
errors
.
New
(
"routing system in offline mode"
)
// NewOfflineRouter returns an IpfsRouting implementation which only performs
// offline operations. It allows to Put and Get signed dht
// records to and from the local datastore.
func
NewOfflineRouter
(
dstore
ds
.
Datastore
,
privkey
ci
.
PrivKey
)
routing
.
IpfsRouting
{
return
&
offlineRouting
{
datastore
:
dstore
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment