diff --git a/zebra-state/src/service.rs b/zebra-state/src/service.rs index 07daf6c2..bb368eaf 100644 --- a/zebra-state/src/service.rs +++ b/zebra-state/src/service.rs @@ -374,8 +374,27 @@ impl Service for StateService { let now = Instant::now(); if self.last_prune + Self::PRUNE_INTERVAL < now { + let tip = self.tip(); + let old_len = self.pending_utxos.len(); + self.pending_utxos.prune(); self.last_prune = now; + + let new_len = self.pending_utxos.len(); + let prune_count = old_len + .checked_sub(new_len) + .expect("prune does not add any utxo requests"); + if prune_count > 0 { + tracing::info!( + ?old_len, + ?new_len, + ?prune_count, + ?tip, + "pruned utxo requests" + ); + } else { + tracing::debug!(len = ?old_len, ?tip, "no utxo requests needed pruning"); + } } Poll::Ready(Ok(())) diff --git a/zebra-state/src/service/pending_utxos.rs b/zebra-state/src/service/pending_utxos.rs index 4ad38c2b..277173f7 100644 --- a/zebra-state/src/service/pending_utxos.rs +++ b/zebra-state/src/service/pending_utxos.rs @@ -61,4 +61,9 @@ impl PendingUtxos { pub fn prune(&mut self) { self.0.retain(|_, chan| chan.receiver_count() > 0); } + + /// Returns the number of utxos that are being waited on. + pub fn len(&self) -> usize { + self.0.len() + } }