aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-12 12:16:45 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commita567c061aa7407e34cd8e8afc7f1b21c2e2c1628 (patch)
treeccf8d725ca118df44b605f6d2963dc49b47c8666
parented67d8155556892f81a7f1a729a5733ed6318743 (diff)
downloaddexon-a567c061aa7407e34cd8e8afc7f1b21c2e2c1628.tar.gz
dexon-a567c061aa7407e34cd8e8afc7f1b21c2e2c1628.tar.zst
dexon-a567c061aa7407e34cd8e8afc7f1b21c2e2c1628.zip
p2p/discover: fix peer discovery (#248)
The refactor in 4cd90e02e23ecf2bb11bcb4bba4fea2ae164ef74 introduced livness checks for nodes. However, the change in 86ec742f975d825f42dd69ebf17b0adaa66542c0 did not properly set the initial liveness check value for verified node. For verified node we should set livenessCheck to 1 initially. Without this change, the node entry will not be properly send to other nodes and the network would be broken.
-rw-r--r--p2p/discover/udp.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index d9665a876..fbc729d81 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -659,6 +659,8 @@ func (req *ping) handle(t *udp, from *net.UDPAddr, fromID enode.ID, mac []byte)
// Ping back if our last pong on file is too far in the past.
n := wrapNode(enode.NewV4(req.senderKey, from.IP, int(req.From.TCP), from.Port))
+ n.livenessChecks++
+
if time.Since(t.db.LastPongReceived(n.ID(), from.IP)) > bondExpiration {
t.sendPing(fromID, from, func() {
t.tab.addVerifiedNode(n)