From 32c8fcec191f5f7b74319f2dcd2447cf016b1441 Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Sun, 2 Jun 2024 20:25:09 +0200 Subject: [PATCH] Move is_connected check to main match --- .../lighthouse_network/src/service/mod.rs | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/beacon_node/lighthouse_network/src/service/mod.rs b/beacon_node/lighthouse_network/src/service/mod.rs index bc04dab8384..343626e9806 100644 --- a/beacon_node/lighthouse_network/src/service/mod.rs +++ b/beacon_node/lighthouse_network/src/service/mod.rs @@ -1378,19 +1378,6 @@ impl Network { ) -> Option> { let peer_id = event.peer_id; - if !self.peer_manager().is_connected(&peer_id) - // Do not permit Inbound events from peers that are being disconnected - && matches!(event.event, HandlerEvent::Err(HandlerErr::Inbound { .. })) - && matches!(event.event, HandlerEvent::Ok(RPCReceived::Request(..))) - { - debug!( - self.log, - "Ignoring rpc message of disconnecting peer"; - event - ); - return None; - } - let handler_id = event.conn_id; // The METADATA and PING RPC responses are handled within the behaviour and not propagated match event.event { @@ -1430,6 +1417,13 @@ impl Network { } } HandlerEvent::Ok(RPCReceived::Request(id, request)) => { + // Ignore Inbound requests from peers that are being disconnected. No point in doing + // work to retrieve data that can't be delivered. + if !self.peer_manager().is_connected(&peer_id) { + debug!(self.log, "Ignoring rpc request of disconnecting peer"; "request" => ?request); + return None; + } + let peer_request_id = (handler_id, id); match request { /* Behaviour managed protocols: Ping and Metadata */