mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: clean up StateFetcher::next_peer (#738)
* refactor: clean up `StateFetcher::next_peer` The `&mut Peer` is unused, so we do not need to return it. * chore: idiomatic rust
This commit is contained in:
@ -103,8 +103,8 @@ impl StateFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the _next_ idle peer that's ready to accept a request.
|
/// Returns the _next_ idle peer that's ready to accept a request.
|
||||||
fn next_peer(&mut self) -> Option<(&PeerId, &mut Peer)> {
|
fn next_peer(&self) -> Option<&PeerId> {
|
||||||
self.peers.iter_mut().find(|(_, peer)| peer.state.is_idle())
|
self.peers.iter().find_map(|(peer_id, peer)| peer.state.is_idle().then_some(peer_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the next action to return
|
/// Returns the next action to return
|
||||||
@ -114,8 +114,8 @@ impl StateFetcher {
|
|||||||
return PollAction::NoRequests
|
return PollAction::NoRequests
|
||||||
}
|
}
|
||||||
|
|
||||||
let peer_id = if let Some(peer) = self.next_peer() {
|
let peer_id = if let Some(peer_id) = self.next_peer() {
|
||||||
*peer.0
|
*peer_id
|
||||||
} else {
|
} else {
|
||||||
return PollAction::NoPeersAvailable
|
return PollAction::NoPeersAvailable
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user