@cryptotaxi247 / kubo / commits / 1493c9d80

dht/bootstrap: logging

Juan Batiz-Benet committed Jan 18, 2015 at 00:58 UTC 1493c9d80ab12ca5549006cc65a1a7a8105aa88e
1 file changed +11 -1
routing/dht/dht_bootstrap.go
+11 -1
@@ -42,6 +42,10 @@ const DefaultBootstrapQueries = 1
42 // queries
43 const DefaultBootstrapPeriod = time.Duration(10 * time.Second)
44
45 +// DefaultBootstrapTimeout specifies how long to wait for a bootstrap query
46 +// to run.
47 +const DefaultBootstrapTimeout = time.Duration(10 * time.Second)
48 +
49 // Bootstrap runs bootstrapping once, then calls SignalBootstrap with default
50 // parameters: DefaultBootstrapQueries and DefaultBootstrapPeriod. This allows
51 // the user to catch an error off the bat if the connections are faulty. It also
@@ -76,10 +80,10 @@ func (dht *IpfsDHT) BootstrapOnSignal(queries int, signal <-chan time.Time) (gop
80 }
81
82 proc := goprocess.Go(func(worker goprocess.Process) {
83 + defer log.Debug("dht bootstrapper shutting down")
84 for {
85 select {
86 case <-worker.Closing():
82 - log.Debug("dht bootstrapper shutting down")
87 return
88
89 case <-signal:
@@ -118,6 +122,12 @@ func (dht *IpfsDHT) BootstrapOnSignal(queries int, signal <-chan time.Time) (gop
122
123 // runBootstrap builds up list of peers by requesting random peer IDs
124 func (dht *IpfsDHT) runBootstrap(ctx context.Context, queries int) error {
125 + bslog := func(msg string) {
126 + log.Debugf("DHT %s dhtRunBootstrap %s -- routing table size: %d", dht.self, msg, dht.routingTable.Size())
127 + }
128 + bslog("start")
129 + defer bslog("end")
130 + defer log.EventBegin(ctx, "dhtRunBootstrap").Done()
131
132 var merr u.MultiErr
133