From b5536605369d4da0eea2d34a1bdacc6f88be8b7b Mon Sep 17 00:00:00 2001 From: Boyu Yang Date: Fri, 29 Dec 2023 22:02:41 +0800 Subject: [PATCH] feat: ban a peer if its last state isn't changed after timeout --- src/protocols/light_client/peers.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/protocols/light_client/peers.rs b/src/protocols/light_client/peers.rs index 3cbd1b3..7bc62aa 100644 --- a/src/protocols/light_client/peers.rs +++ b/src/protocols/light_client/peers.rs @@ -1856,6 +1856,15 @@ impl Peers { None } }) + .or_else(|| { + peer.state.get_last_state().and_then(|state| { + if now > state.update_ts + MESSAGE_TIMEOUT { + Some(*peer_index) + } else { + None + } + }) + }) .or_else(|| { peer.get_blocks_proof_request().and_then(|req| { if now > req.when_sent + MESSAGE_TIMEOUT {