From 1503f7d652d63483236c35e47ac8a3a28a73aad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Wed, 19 Jun 2024 06:02:34 +0100 Subject: [PATCH] report failed requests from `RPC` after being clear from rate limiter but not yet sent. (#5942) * report failed rpc requests from RPC --- beacon_node/lighthouse_network/src/rpc/mod.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/beacon_node/lighthouse_network/src/rpc/mod.rs b/beacon_node/lighthouse_network/src/rpc/mod.rs index 1fa6862351..027af89edf 100644 --- a/beacon_node/lighthouse_network/src/rpc/mod.rs +++ b/beacon_node/lighthouse_network/src/rpc/mod.rs @@ -316,6 +316,27 @@ where self.events.push(error_msg); } } + + // Replace the pending Requests to the disconnected peer + // with reports of failed requests. + self.events.iter_mut().for_each(|event| match &event { + ToSwarm::NotifyHandler { + peer_id: p, + event: RPCSend::Request(request_id, req), + .. + } if *p == peer_id => { + *event = ToSwarm::GenerateEvent(RPCMessage { + peer_id, + conn_id: connection_id, + event: HandlerEvent::Err(HandlerErr::Outbound { + id: *request_id, + proto: req.versioned_protocol().protocol(), + error: RPCError::Disconnected, + }), + }); + } + _ => {} + }); } }