refactor: refactor get_idle_peer_for to use Iterator::find (#21321)

This commit is contained in:
iPLAY888
2026-01-23 18:56:09 +03:00
committed by GitHub
parent 1f536cce65
commit d3846d98a9

View File

@@ -188,13 +188,7 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
let TxFetchMetadata { fallback_peers, .. } =
self.hashes_fetch_inflight_and_pending_fetch.peek(&hash)?;
for peer_id in fallback_peers.iter() {
if self.is_idle(peer_id) {
return Some(peer_id)
}
}
None
fallback_peers.iter().find(|peer_id| self.is_idle(peer_id))
}
/// Returns any idle peer for any hash pending fetch. If one is found, the corresponding