From dd9c1b6243b9292980e474f553f58e93fb6f7f3f Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 20 Jan 2015 17:22:14 -0800 Subject: [PATCH] core/bootstrap: CR comments --- core/bootstrap.go | 7 ++++--- routing/dht/dht_bootstrap.go | 1 + routing/dht/dht_test.go | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/bootstrap.go b/core/bootstrap.go index 74b2253ff..b1b0bfaa4 100644 --- a/core/bootstrap.go +++ b/core/bootstrap.go @@ -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.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)) @@ -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) diff --git a/routing/dht/dht_bootstrap.go b/routing/dht/dht_bootstrap.go index c3991972c..588bcfd75 100644 --- a/routing/dht/dht_bootstrap.go +++ b/routing/dht/dht_bootstrap.go @@ -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) } diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index afc5756e8..2e1e1129f 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -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: