mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 18:31:05 +00:00
Implement prune only stagnant check mode (#5761)
* Limit number of elements loaded from the stagnant key This will likely be required if we enable stagnant prunning as currently database has way too many entries to be prunned in a single iteration * Fmt run * Slightly improve logging * Some more debug nits * Fmt pass * Add stagnant prunning delay * Enable stagnant check worker * Implement stagnant pruning without stagnant checks * Update node/core/chain-selection/src/tree.rs Co-authored-by: Andronik <write@reusable.software> * Apply suggestions from code review Co-authored-by: Andronik <write@reusable.software> Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
@@ -552,7 +552,7 @@ pub(super) fn detect_stagnant<'a, B: 'a + Backend>(
|
||||
?up_to,
|
||||
?min_ts,
|
||||
?max_ts,
|
||||
"Prepared {} stagnant entries for pruning",
|
||||
"Prepared {} stagnant entries for checking/pruning",
|
||||
stagnant_up_to.len()
|
||||
);
|
||||
|
||||
@@ -594,6 +594,39 @@ pub(super) fn detect_stagnant<'a, B: 'a + Backend>(
|
||||
Ok(backend)
|
||||
}
|
||||
|
||||
/// Prune stagnant entries at some timestamp without other checks
|
||||
/// This function is intended just to clean leftover entries when the real
|
||||
/// stagnant checks are disabled
|
||||
pub(super) fn prune_only_stagnant<'a, B: 'a + Backend>(
|
||||
backend: &'a B,
|
||||
up_to: Timestamp,
|
||||
max_elements: usize,
|
||||
) -> Result<OverlayedBackend<'a, B>, Error> {
|
||||
let stagnant_up_to = backend.load_stagnant_at_up_to(up_to, max_elements)?;
|
||||
let mut backend = OverlayedBackend::new(backend);
|
||||
|
||||
let (min_ts, max_ts) = match stagnant_up_to.len() {
|
||||
0 => (0 as Timestamp, 0 as Timestamp),
|
||||
1 => (stagnant_up_to[0].0, stagnant_up_to[0].0),
|
||||
n => (stagnant_up_to[0].0, stagnant_up_to[n - 1].0),
|
||||
};
|
||||
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?up_to,
|
||||
?min_ts,
|
||||
?max_ts,
|
||||
"Prepared {} stagnant entries for pruning",
|
||||
stagnant_up_to.len()
|
||||
);
|
||||
|
||||
for (timestamp, _) in stagnant_up_to {
|
||||
backend.delete_stagnant_at(timestamp);
|
||||
}
|
||||
|
||||
Ok(backend)
|
||||
}
|
||||
|
||||
/// Revert the tree to the block relative to `hash`.
|
||||
///
|
||||
/// This accepts a fresh backend and returns an overlay on top of it representing
|
||||
|
||||
Reference in New Issue
Block a user