From 4cd90e02e23ecf2bb11bcb4bba4fea2ae164ef74 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 29 Jan 2019 17:39:20 +0100 Subject: p2p/discover, p2p/enode: rework endpoint proof handling, packet logging (#18963) This change resolves multiple issues around handling of endpoint proofs. The proof is now done separately for each IP and completing the proof requires a matching ping hash. Also remove waitping because it's equivalent to sleep. waitping was slightly more efficient, but that may cause issues with findnode if packets are reordered and the remote end sees findnode before pong. Logging of received packets was hitherto done after handling the packet, which meant that sent replies were logged before the packet that generated them. This change splits up packet handling into 'preverify' and 'handle'. The error from 'preverify' is logged, but 'handle' happens after the message is logged. This fixes the order. Packet logs now contain the node ID. --- p2p/discover/node.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'p2p/discover/node.go') diff --git a/p2p/discover/node.go b/p2p/discover/node.go index 7ddf04fe8..8d4af166b 100644 --- a/p2p/discover/node.go +++ b/p2p/discover/node.go @@ -33,7 +33,8 @@ import ( // The fields of Node may not be modified. type node struct { enode.Node - addedAt time.Time // time when the node was added to the table + addedAt time.Time // time when the node was added to the table + livenessChecks uint // how often liveness was checked } type encPubkey [64]byte -- cgit v1.2.3