aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-12 12:16:45 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:22 +0800
commit7fe778e601a9371c498ce9262d35b95daa1cc362 (patch)
treeaabcb9b1f0c82141f4173ec46d8301c211920b96
parent9f881468d081c0627403cc5058ef4ee72fe9f933 (diff)
downloadgo-tangerine-7fe778e601a9371c498ce9262d35b95daa1cc362.tar.gz
go-tangerine-7fe778e601a9371c498ce9262d35b95daa1cc362.tar.zst
go-tangerine-7fe778e601a9371c498ce9262d35b95daa1cc362.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)