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-unixfs
Commits
dd9c1b62
Commit
dd9c1b62
authored
Jan 20, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/bootstrap: CR comments
parent
d6ce837d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
core/bootstrap.go
core/bootstrap.go
+4
-3
routing/dht/dht_bootstrap.go
routing/dht/dht_bootstrap.go
+1
-0
routing/dht/dht_test.go
routing/dht/dht_test.go
+0
-2
No files found.
core/bootstrap.go
View file @
dd9c1b62
...
...
@@ -93,6 +93,7 @@ func (nb *nodeBootstrapper) TryToBootstrap(ctx context.Context, peers []peer.Pee
// kick off the node's periodic bootstrapping
proc
:=
periodicproc
.
Tick
(
BootstrapPeriod
,
func
(
worker
goprocess
.
Process
)
{
defer
log
.
EventBegin
(
ctx
,
"periodicBootstrap"
,
n
.
Identity
)
.
Done
()
if
err
:=
bootstrapRound
(
ctx
,
n
.
PeerHost
,
dht
,
n
.
Peerstore
,
peers
);
err
!=
nil
{
log
.
Error
(
err
)
}
...
...
@@ -158,8 +159,8 @@ func bootstrapRound(ctx context.Context,
}
// connect to a random susbset of bootstrap candidates
var
randomSubset
=
randomSubsetOfPeers
(
notConnected
,
numCxnsToCreate
)
log
.
Event
(
ctx
,
"bootstrapStart"
,
host
.
ID
())
randomSubset
:
=
randomSubsetOfPeers
(
notConnected
,
numCxnsToCreate
)
defer
log
.
Event
Begin
(
ctx
,
"bootstrapStart"
,
host
.
ID
())
.
Done
()
log
.
Debugf
(
"%s bootstrapping to %d nodes: %s"
,
host
.
ID
(),
numCxnsToCreate
,
randomSubset
)
if
err
:=
bootstrapConnect
(
ctx
,
peerstore
,
route
,
randomSubset
);
err
!=
nil
{
log
.
Event
(
ctx
,
"bootstrapError"
,
host
.
ID
(),
lgbl
.
Error
(
err
))
...
...
@@ -189,7 +190,7 @@ func bootstrapConnect(ctx context.Context,
wg
.
Add
(
1
)
go
func
(
p
peer
.
PeerInfo
)
{
defer
wg
.
Done
()
log
.
Event
(
ctx
,
"bootstrapDial"
,
route
.
LocalPeer
(),
p
.
ID
)
defer
log
.
Event
Begin
(
ctx
,
"bootstrapDial"
,
route
.
LocalPeer
(),
p
.
ID
)
.
Done
()
log
.
Debugf
(
"%s bootstrapping to %s"
,
route
.
LocalPeer
(),
p
.
ID
)
ps
.
AddAddresses
(
p
.
ID
,
p
.
Addrs
)
...
...
routing/dht/dht_bootstrap.go
View file @
dd9c1b62
...
...
@@ -128,6 +128,7 @@ func (dht *IpfsDHT) runBootstrap(ctx context.Context, queries int) error {
// the dht will rehash to its own keyspace anyway.
id
:=
make
([]
byte
,
16
)
rand
.
Read
(
id
)
id
=
u
.
Hash
(
id
)
return
peer
.
ID
(
id
)
}
...
...
routing/dht/dht_test.go
View file @
dd9c1b62
...
...
@@ -75,8 +75,6 @@ func connect(t *testing.T, ctx context.Context, a, b *IpfsDHT) {
func
bootstrap
(
t
*
testing
.
T
,
ctx
context
.
Context
,
dhts
[]
*
IpfsDHT
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
log
.
Error
(
"hmm"
)
defer
log
.
Error
(
"hmm end"
)
log
.
Debugf
(
"bootstrapping dhts..."
)
// tried async. sequential fares much better. compare:
...
...
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