@cryptotaxi247 / kubo / commits / dd9c1b624

core/bootstrap: CR comments

Juan Batiz-Benet committed Jan 20, 2015 at 17:22 UTC dd9c1b6243b9292980e474f553f58e93fb6f7f3f
3 files changed +5 -5
core/bootstrap.go
+4 -3
@@ -93,6 +93,7 @@ func (nb *nodeBootstrapper) TryToBootstrap(ctx context.Context, peers []peer.Pee
93
94 // kick off the node's periodic bootstrapping
95 proc := periodicproc.Tick(BootstrapPeriod, func(worker goprocess.Process) {
96 + defer log.EventBegin(ctx, "periodicBootstrap", n.Identity).Done()
97 if err := bootstrapRound(ctx, n.PeerHost, dht, n.Peerstore, peers); err != nil {
98 log.Error(err)
99 }
@@ -158,8 +159,8 @@ func bootstrapRound(ctx context.Context,
159 }
160
161 // connect to a random susbset of bootstrap candidates
161 - var randomSubset = randomSubsetOfPeers(notConnected, numCxnsToCreate)
162 - log.Event(ctx, "bootstrapStart", host.ID())
162 + randomSubset := randomSubsetOfPeers(notConnected, numCxnsToCreate)
163 + defer log.EventBegin(ctx, "bootstrapStart", host.ID()).Done()
164 log.Debugf("%s bootstrapping to %d nodes: %s", host.ID(), numCxnsToCreate, randomSubset)
165 if err := bootstrapConnect(ctx, peerstore, route, randomSubset); err != nil {
166 log.Event(ctx, "bootstrapError", host.ID(), lgbl.Error(err))
@@ -189,7 +190,7 @@ func bootstrapConnect(ctx context.Context,
190 wg.Add(1)
191 go func(p peer.PeerInfo) {
192 defer wg.Done()
192 - log.Event(ctx, "bootstrapDial", route.LocalPeer(), p.ID)
193 + defer log.EventBegin(ctx, "bootstrapDial", route.LocalPeer(), p.ID).Done()
194 log.Debugf("%s bootstrapping to %s", route.LocalPeer(), p.ID)
195
196 ps.AddAddresses(p.ID, p.Addrs)
routing/dht/dht_bootstrap.go
+1
@@ -128,6 +128,7 @@ func (dht *IpfsDHT) runBootstrap(ctx context.Context, queries int) error {
128 // the dht will rehash to its own keyspace anyway.
129 id := make([]byte, 16)
130 rand.Read(id)
131 + id = u.Hash(id)
132 return peer.ID(id)
133 }
134
routing/dht/dht_test.go
-2
@@ -75,8 +75,6 @@ func connect(t *testing.T, ctx context.Context, a, b *IpfsDHT) {
75 func bootstrap(t *testing.T, ctx context.Context, dhts []*IpfsDHT) {
76
77 ctx, cancel := context.WithCancel(ctx)
78 - log.Error("hmm")
79 - defer log.Error("hmm end")
78 log.Debugf("bootstrapping dhts...")
79
80 // tried async. sequential fares much better. compare: