From 0b97d29c476c431d35de2575cd8959ed8710d744 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 17 Oct 2014 17:54:47 -0700 Subject: [PATCH] small changes to auxiliary dht functions --- routing/dht/dht.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/routing/dht/dht.go b/routing/dht/dht.go index 22523f0bb..2d4c9852e 100644 --- a/routing/dht/dht.go +++ b/routing/dht/dht.go @@ -23,6 +23,8 @@ import ( var log = u.Logger("dht") +const doPinging = true + // TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js // IpfsDHT is an implementation of Kademlia with Coral and S/Kademlia modifications. @@ -75,7 +77,9 @@ func NewDHT(ctx context.Context, p *peer.Peer, ps peer.Peerstore, net inet.Netwo dht.routingTables[2] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID), time.Hour) dht.birth = time.Now() - go dht.PingRoutine(time.Second * 10) + if doPinging { + go dht.PingRoutine(time.Second * 10) + } return dht } @@ -562,5 +566,8 @@ func (dht *IpfsDHT) PingRoutine(t time.Duration) { func (dht *IpfsDHT) Bootstrap(ctx context.Context) { id := make([]byte, 16) rand.Read(id) - dht.FindPeer(ctx, peer.ID(id)) + _, err := dht.FindPeer(ctx, peer.ID(id)) + if err != nil { + log.Error("Bootstrap peer error: %s", err) + } }