p2p/discover: panic instead of error log for missing node

This commit is contained in:
Felix Lange 2025-04-02 13:26:25 +02:00
parent 3b4fd32f94
commit 66e3b383d4

View file

@ -72,10 +72,11 @@ func (t *talkSystem) register(protocol string, handler TalkRequestHandler) {
// handleRequest handles a talk request. // handleRequest handles a talk request.
func (t *talkSystem) handleRequest(id enode.ID, addr netip.AddrPort, req *v5wire.TalkRequest) { func (t *talkSystem) handleRequest(id enode.ID, addr netip.AddrPort, req *v5wire.TalkRequest) {
var n *enode.Node n := t.transport.codec.SessionNode(id, addr.String())
if n = t.transport.codec.SessionNode(id, addr.String()); n == nil { if n == nil {
log.Error("Got a TALKREQ from a node that has not completed the handshake", "id", id, "addr", addr) // The node must be contained in the session here, since we wouldn't have
return // received the request otherwise.
panic("missing node in session")
} }
t.mutex.Lock() t.mutex.Lock()
handler, ok := t.handlers[req.Protocol] handler, ok := t.handlers[req.Protocol]