diff --git a/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs b/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs index c7fce028d42b..95ecf35557a5 100644 --- a/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs +++ b/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs @@ -98,17 +98,12 @@ impl OnDemandJustificationsEngine>) -> Option { - let live = self.live_peers.lock(); - - if let Some(reset) = reset_cache { - self.peers_cache = live.further_than(reset); - } + fn reset_peers_cache_for_block(&mut self, block: NumberFor) { + self.peers_cache = self.live_peers.lock().further_than(block); + } + fn try_next_peer(&mut self) -> Option { + let live = self.live_peers.lock(); while let Some(peer) = self.peers_cache.pop_front() { if live.contains(&peer) { return Some(peer); @@ -147,10 +142,11 @@ impl OnDemandJustificationsEngine OnDemandJustificationsEngine { // No valid justification received, try next peer in our set. - if let Some(peer) = self.try_next_peer(None) { + if let Some(peer) = self.try_next_peer() { self.request_from_peer(peer, req_info); } else { metric_inc!(