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-routing
Commits
acff6928
Commit
acff6928
authored
Feb 03, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(routing) expose Bootstrap() error on routing interface
parent
d4c2e064
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
1 deletion
+21
-1
dht/dht_bootstrap.go
dht/dht_bootstrap.go
+7
-1
mock/centralized_client.go
mock/centralized_client.go
+4
-0
offline/offline.go
offline/offline.go
+4
-0
routing.go
routing.go
+6
-0
No files found.
dht/dht_bootstrap.go
View file @
acff6928
...
...
@@ -4,6 +4,7 @@ package dht
import
(
"crypto/rand"
"errors"
"fmt"
"sync"
"time"
...
...
@@ -44,13 +45,18 @@ var DefaultBootstrapConfig = BootstrapConfig{
Timeout
:
time
.
Duration
(
20
*
time
.
Second
),
}
func
(
dht
*
IpfsDHT
)
Bootstrap
(
context
.
Context
)
error
{
// Bootstrap satisfies the routing interface
return
errors
.
New
(
"TODO: perform DHT bootstrap"
)
}
// Bootstrap ensures the dht routing table remains healthy as peers come and go.
// it builds up a list of peers by requesting random peer IDs. The Bootstrap
// process will run a number of queries each time, and run every time signal fires.
// These parameters are configurable.
//
// Bootstrap returns a process, so the user can stop it.
func
(
dht
*
IpfsDHT
)
Bootstrap
(
config
BootstrapConfig
)
(
goprocess
.
Process
,
error
)
{
func
(
dht
*
IpfsDHT
)
Bootstrap
WithConfig
(
config
BootstrapConfig
)
(
goprocess
.
Process
,
error
)
{
sig
:=
time
.
Tick
(
config
.
Period
)
return
dht
.
BootstrapOnSignal
(
config
,
sig
)
}
...
...
mock/centralized_client.go
View file @
acff6928
...
...
@@ -84,4 +84,8 @@ func (c *client) Ping(ctx context.Context, p peer.ID) (time.Duration, error) {
return
0
,
nil
}
func
(
c
*
client
)
Bootstrap
(
context
.
Context
)
error
{
return
nil
}
var
_
routing
.
IpfsRouting
=
&
client
{}
offline/offline.go
View file @
acff6928
...
...
@@ -89,5 +89,9 @@ func (c *offlineRouting) Ping(ctx context.Context, p peer.ID) (time.Duration, er
return
0
,
ErrOffline
}
func
(
c
*
offlineRouting
)
Bootstrap
(
context
.
Context
)
(
error
)
{
return
nil
}
// ensure offlineRouting matches the IpfsRouting interface
var
_
routing
.
IpfsRouting
=
&
offlineRouting
{}
routing.go
View file @
acff6928
...
...
@@ -40,4 +40,10 @@ type IpfsRouting interface {
// Ping a peer, log the time it took
Ping
(
context
.
Context
,
peer
.
ID
)
(
time
.
Duration
,
error
)
// Bootstrap allows callers to hint to the routing system to get into a
// Boostrapped state
Bootstrap
(
context
.
Context
)
error
// TODO expose io.Closer or plain-old Close error
}
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