From 3502bc5c1d51e8383669e254c55f50e855003538 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Wed, 18 May 2022 03:42:53 -0400 Subject: [PATCH] Return a successful response on repeated small block request (#11429) --- .../client/network/sync/src/block_request_handler.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/substrate/client/network/sync/src/block_request_handler.rs b/substrate/client/network/sync/src/block_request_handler.rs index 78d6a1a7d1..4cd69d1fac 100644 --- a/substrate/client/network/sync/src/block_request_handler.rs +++ b/substrate/client/network/sync/src/block_request_handler.rs @@ -204,15 +204,15 @@ where let mut reputation_change = None; + let small_request = attributes + .difference(BlockAttributes::HEADER | BlockAttributes::JUSTIFICATION) + .is_empty(); + match self.seen_requests.get_mut(&key) { Some(SeenRequestsValue::First) => {}, Some(SeenRequestsValue::Fulfilled(ref mut requests)) => { *requests = requests.saturating_add(1); - let small_request = attributes - .difference(BlockAttributes::HEADER | BlockAttributes::JUSTIFICATION) - .is_empty(); - if *requests > MAX_NUMBER_OF_SAME_REQUESTS_PER_PEER { reputation_change = Some(if small_request { rep::SAME_SMALL_REQUEST @@ -237,7 +237,7 @@ where attributes, ); - let result = if reputation_change.is_none() { + let result = if reputation_change.is_none() || small_request { let block_response = self.get_block_response( attributes, from_block_id,