From 66e3b383d46fd631f69ec3bfb952b55126c64099 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 2 Apr 2025 13:26:25 +0200 Subject: [PATCH] p2p/discover: panic instead of error log for missing node --- p2p/discover/v5_talk.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/p2p/discover/v5_talk.go b/p2p/discover/v5_talk.go index 10c4983d5a..dca09870d8 100644 --- a/p2p/discover/v5_talk.go +++ b/p2p/discover/v5_talk.go @@ -72,10 +72,11 @@ func (t *talkSystem) register(protocol string, handler TalkRequestHandler) { // handleRequest handles a talk request. func (t *talkSystem) handleRequest(id enode.ID, addr netip.AddrPort, req *v5wire.TalkRequest) { - var n *enode.Node - if n = t.transport.codec.SessionNode(id, addr.String()); n == nil { - log.Error("Got a TALKREQ from a node that has not completed the handshake", "id", id, "addr", addr) - return + n := t.transport.codec.SessionNode(id, addr.String()) + if n == nil { + // The node must be contained in the session here, since we wouldn't have + // received the request otherwise. + panic("missing node in session") } t.mutex.Lock() handler, ok := t.handlers[req.Protocol]