@cryptotaxi247 / kubo / commits / 0b97d29c4

small changes to auxiliary dht functions

Jeromy committed Oct 17, 2014 at 17:54 UTC 0b97d29c476c431d35de2575cd8959ed8710d744
1 file changed +9 -2
routing/dht/dht.go
+9 -2
@@ -23,6 +23,8 @@ import (
23
24 var log = u.Logger("dht")
25
26 +const doPinging = true
27 +
28 // TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js
29
30 // 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
77 dht.routingTables[2] = kb.NewRoutingTable(20, kb.ConvertPeerID(p.ID), time.Hour)
78 dht.birth = time.Now()
79
78 - go dht.PingRoutine(time.Second * 10)
80 + if doPinging {
81 + go dht.PingRoutine(time.Second * 10)
82 + }
83 return dht
84 }
85
@@ -562,5 +566,8 @@ func (dht *IpfsDHT) PingRoutine(t time.Duration) {
566 func (dht *IpfsDHT) Bootstrap(ctx context.Context) {
567 id := make([]byte, 16)
568 rand.Read(id)
565 - dht.FindPeer(ctx, peer.ID(id))
569 + _, err := dht.FindPeer(ctx, peer.ID(id))
570 + if err != nil {
571 + log.Error("Bootstrap peer error: %s", err)
572 + }
573 }