@cryptotaxi247 / kubo / commits / 7d7e05110

dht bootstrap err check fix + logging

Juan Batiz-Benet committed Dec 23, 2014 at 19:02 UTC 7d7e0511012d6bdd886f6f0a06327584a62cd468
2 files changed +7 -6
routing/dht/dht.go
+6 -5
@@ -372,13 +372,14 @@ func (dht *IpfsDHT) Bootstrap(ctx context.Context) {
372 id := make([]byte, 16)
373 rand.Read(id)
374 pi, err := dht.FindPeer(ctx, peer.ID(id))
375 - if err != nil {
376 - // NOTE: this is not an error. this is expected!
375 + if err == routing.ErrNotFound {
376 + // this isn't an error. this is precisely what we expect.
377 + } else if err != nil {
378 log.Errorf("Bootstrap peer error: %s", err)
379 + } else {
380 + // woah, we got a peer under a random id? it _cannot_ be valid.
381 + log.Errorf("dht seemingly found a peer at a random bootstrap id (%s)...", pi)
382 }
379 -
380 - // woah, we got a peer under a random id? it _cannot_ be valid.
381 - log.Errorf("dht seemingly found a peer at a random bootstrap id (%s)...", pi)
383 }()
384 }
385 wg.Wait()
routing/dht/handlers.go
+1 -1
@@ -148,7 +148,7 @@ func (dht *IpfsDHT) handleFindPeer(ctx context.Context, p peer.ID, pmes *pb.Mess
148 }
149
150 if closest == nil {
151 - log.Errorf("handleFindPeer: could not find anything.")
151 + log.Debugf("handleFindPeer: could not find anything.")
152 return resp, nil
153 }
154