Skip to content

Commit c5764f5

Browse files
soniseth0mattsse
andauthored
chore: avoid cloning block range when ranking peers (#20033)
Co-authored-by: Matthias Seitz <[email protected]>
1 parent 6becc6b commit c5764f5

File tree

1 file changed

+2
-4
lines changed
  • crates/net/network/src/fetch

1 file changed

+2
-4
lines changed

crates/net/network/src/fetch/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl Peer {
399399
/// 2. None can fully cover the range, but this peer has lower start value
400400
/// 3. If a peer doesnt announce a range we assume it has full history, but check the other's
401401
/// range and treat that as better if it can cover the range
402-
fn has_better_range(&self, other: &Self, range: RangeInclusive<u64>) -> bool {
402+
fn has_better_range(&self, other: &Self, range: &RangeInclusive<u64>) -> bool {
403403
let self_range = self.range();
404404
let other_range = other.range();
405405

@@ -438,9 +438,7 @@ impl Peer {
438438
fn is_better(&self, other: &Self, requirement: &BestPeerRequirements) -> bool {
439439
match requirement {
440440
BestPeerRequirements::None => false,
441-
BestPeerRequirements::FullBlockRange(range) => {
442-
self.has_better_range(other, range.clone())
443-
}
441+
BestPeerRequirements::FullBlockRange(range) => self.has_better_range(other, range),
444442
BestPeerRequirements::FullBlock => self.has_full_history() && !other.has_full_history(),
445443
}
446444
}

0 commit comments

Comments
 (0)