aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/udp.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2019-01-31 18:48:54 +0800
committerFelix Lange <fjl@twurst.com>2019-01-31 18:51:13 +0800
commit86ec742f975d825f42dd69ebf17b0adaa66542c0 (patch)
tree62093f7c5436664adc5d5db9aec65ed1a6e6bd0c /p2p/discover/udp.go
parentd9a07fba67d2fc5944de9b62136233d367dc98b0 (diff)
downloadgo-tangerine-86ec742f975d825f42dd69ebf17b0adaa66542c0.tar
go-tangerine-86ec742f975d825f42dd69ebf17b0adaa66542c0.tar.gz
go-tangerine-86ec742f975d825f42dd69ebf17b0adaa66542c0.tar.bz2
go-tangerine-86ec742f975d825f42dd69ebf17b0adaa66542c0.tar.lz
go-tangerine-86ec742f975d825f42dd69ebf17b0adaa66542c0.tar.xz
go-tangerine-86ec742f975d825f42dd69ebf17b0adaa66542c0.tar.zst
go-tangerine-86ec742f975d825f42dd69ebf17b0adaa66542c0.zip
p2p/discover: improve table addition code (#18974)
This change clears up confusion around the two ways in which nodes can be added to the table. When a neighbors packet is received as a reply to findnode, the nodes contained in the reply are added as 'seen' entries if sufficient space is available. When a ping is received and the endpoint verification has taken place, the remote node is added as a 'verified' entry or moved to the front of the bucket if present. This also updates the node's IP address and port if they have changed.
Diffstat (limited to 'p2p/discover/udp.go')
-rw-r--r--p2p/discover/udp.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index 5ce4c43dc..df9a3065f 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -661,10 +661,10 @@ func (req *ping) handle(t *udp, from *net.UDPAddr, fromID enode.ID, mac []byte)
n := wrapNode(enode.NewV4(req.senderKey, from.IP, int(req.From.TCP), from.Port))
if time.Since(t.db.LastPongReceived(n.ID(), from.IP)) > bondExpiration {
t.sendPing(fromID, from, func() {
- t.tab.addThroughPing(n)
+ t.tab.addVerifiedNode(n)
})
} else {
- t.tab.addThroughPing(n)
+ t.tab.addVerifiedNode(n)
}
// Update node database and endpoint predictor.