Add an info-level log when UTXO requests are pruned (#1396)
And a debug-level log when no requests are pruned. I'm seeing some hangs during the initial sync, these logs might help identify the cause.
This commit is contained in:
parent
fc7d37c984
commit
176923a771
|
|
@ -374,8 +374,27 @@ impl Service<Request> for StateService {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
if self.last_prune + Self::PRUNE_INTERVAL < 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.pending_utxos.prune();
|
||||||
self.last_prune = now;
|
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(()))
|
Poll::Ready(Ok(()))
|
||||||
|
|
|
||||||
|
|
@ -61,4 +61,9 @@ impl PendingUtxos {
|
||||||
pub fn prune(&mut self) {
|
pub fn prune(&mut self) {
|
||||||
self.0.retain(|_, chan| chan.receiver_count() > 0);
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue