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-04-09 21:32:58 +0800
commit46d50cf0f0bbe2ef38ea150ed5e4df9bd3754908 (patch)
tree88e351a16b7131944dae394072671f4830facaa3
parent32fcefbe8d9c3f5e6b0732d9d33854d6f1333480 (diff)
downloaddexon-46d50cf0f0bbe2ef38ea150ed5e4df9bd3754908.tar.gz
dexon-46d50cf0f0bbe2ef38ea150ed5e4df9bd3754908.tar.zst
dexon-46d50cf0f0bbe2ef38ea150ed5e4df9bd3754908.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)