Skip to content

Commit

Permalink
core/bootstrap: CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenet committed Jan 23, 2015
1 parent d6ce837 commit dd9c1b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions core/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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.EventBegin(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))
Expand Down Expand Up @@ -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.EventBegin(ctx, "bootstrapDial", route.LocalPeer(), p.ID).Done()
log.Debugf("%s bootstrapping to %s", route.LocalPeer(), p.ID)

ps.AddAddresses(p.ID, p.Addrs)
Expand Down
1 change: 1 addition & 0 deletions routing/dht/dht_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 0 additions & 2 deletions routing/dht/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dd9c1b6

Please sign in to comment.