mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: active inflight count (#11598)
This commit is contained in:
@ -98,6 +98,11 @@ pub struct TransactionFetcher {
|
||||
// === impl TransactionFetcher ===
|
||||
|
||||
impl TransactionFetcher {
|
||||
/// Removes the peer from the active set.
|
||||
pub(crate) fn remove_peer(&mut self, peer_id: &PeerId) {
|
||||
self.active_peers.remove(peer_id);
|
||||
}
|
||||
|
||||
/// Updates metrics.
|
||||
#[inline]
|
||||
pub fn update_metrics(&self) {
|
||||
@ -157,7 +162,7 @@ impl TransactionFetcher {
|
||||
fn decrement_inflight_request_count_for(&mut self, peer_id: &PeerId) {
|
||||
let remove = || -> bool {
|
||||
if let Some(inflight_count) = self.active_peers.get(peer_id) {
|
||||
*inflight_count -= 1;
|
||||
*inflight_count = inflight_count.saturating_sub(1);
|
||||
if *inflight_count == 0 {
|
||||
return true
|
||||
}
|
||||
@ -659,8 +664,6 @@ impl TransactionFetcher {
|
||||
return Some(new_announced_hashes)
|
||||
}
|
||||
|
||||
*inflight_count += 1;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
for hash in &new_announced_hashes {
|
||||
@ -695,6 +698,8 @@ impl TransactionFetcher {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*inflight_count += 1;
|
||||
// stores a new request future for the request
|
||||
self.inflight_requests.push(GetPooledTxRequestFut::new(peer_id, new_announced_hashes, rx));
|
||||
|
||||
|
||||
@ -904,6 +904,7 @@ where
|
||||
NetworkEvent::SessionClosed { peer_id, .. } => {
|
||||
// remove the peer
|
||||
self.peers.remove(&peer_id);
|
||||
self.transaction_fetcher.remove_peer(&peer_id);
|
||||
}
|
||||
NetworkEvent::SessionEstablished {
|
||||
peer_id, client_version, messages, version, ..
|
||||
|
||||
Reference in New Issue
Block a user