Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Return a successful response on repeated small block request (#11429)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit authored May 18, 2022
1 parent c00ed05 commit d45e383
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/network/sync/src/block_request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit d45e383

Please sign in to comment.