diff options
author | Felix Lange <fjl@twurst.com> | 2017-02-24 16:58:04 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2017-02-28 17:20:29 +0800 |
commit | 96ae35e2ac8c360781407d7294081aabdcbb3652 (patch) | |
tree | 378cc7aae99127a4e85a721e5cd319ced87e103a /p2p/discover/table.go | |
parent | 35e8308bf76df11c3c1e8d11fac782814583ea5c (diff) | |
download | dexon-96ae35e2ac8c360781407d7294081aabdcbb3652.tar dexon-96ae35e2ac8c360781407d7294081aabdcbb3652.tar.gz dexon-96ae35e2ac8c360781407d7294081aabdcbb3652.tar.bz2 dexon-96ae35e2ac8c360781407d7294081aabdcbb3652.tar.lz dexon-96ae35e2ac8c360781407d7294081aabdcbb3652.tar.xz dexon-96ae35e2ac8c360781407d7294081aabdcbb3652.tar.zst dexon-96ae35e2ac8c360781407d7294081aabdcbb3652.zip |
p2p, p2p/discover, p2p/nat: rework logging using context keys
Diffstat (limited to 'p2p/discover/table.go')
-rw-r--r-- | p2p/discover/table.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 03392b563..2f5a26c34 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -277,10 +277,10 @@ func (tab *Table) lookup(targetID NodeID, refreshIfEmpty bool) []*Node { // Bump the failure counter to detect and evacuate non-bonded entries fails := tab.db.findFails(n.ID) + 1 tab.db.updateFindFails(n.ID, fails) - log.Trace(fmt.Sprintf("Bumping failures for %x: %d", n.ID[:8], fails)) + log.Trace("Bumping findnode failure counter", "id", n.ID, "failcount", fails) if fails >= maxFindnodeFailures { - log.Trace(fmt.Sprintf("Evacuating node %x: %d findnode failures", n.ID[:8], fails)) + log.Trace("Too many findnode failures, dropping", "id", n.ID, "failcount", fails) tab.delete(n) } } @@ -385,13 +385,11 @@ func (tab *Table) doRefresh(done chan struct{}) { seeds = tab.bondall(append(seeds, tab.nursery...)) if len(seeds) == 0 { - log.Debug(fmt.Sprintf("no seed nodes found")) + log.Debug("No discv4 seed nodes found") } for _, n := range seeds { - log.Debug("", "msg", log.Lazy{Fn: func() string { - age := time.Since(tab.db.lastPong(n.ID)) - return fmt.Sprintf("seed node (age %v): %v", age, n) - }}) + age := log.Lazy{Fn: func() time.Duration { return time.Since(tab.db.lastPong(n.ID)) }} + log.Trace("Found seed node in database", "id", n.ID, "addr", n.addr(), "age", age) } tab.mutex.Lock() tab.stuff(seeds) @@ -470,7 +468,7 @@ func (tab *Table) bond(pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16 var result error age := time.Since(tab.db.lastPong(id)) if node == nil || fails > 0 || age > nodeDBNodeExpiration { - log.Trace(fmt.Sprintf("Bonding %x: known=%t, fails=%d age=%v", id[:8], node != nil, fails, age)) + log.Trace("Starting bonding ping/pong", "id", id, "known", node != nil, "failcount", fails, "age", age) tab.bondmu.Lock() w := tab.bonding[id] |