Limit stagnant checks to a certain amount of entries (#5742)

* 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
This commit is contained in:
Vsevolod Stakhov
2022-07-04 09:08:27 +01:00
committed by GitHub
parent 6d672f0951
commit 9dc99f0229
5 changed files with 65 additions and 13 deletions
@@ -139,13 +139,16 @@ impl Backend for TestBackend {
fn load_stagnant_at_up_to(
&self,
up_to: Timestamp,
max_elements: usize,
) -> Result<Vec<(Timestamp, Vec<Hash>)>, Error> {
Ok(self
.inner
.lock()
.stagnant_at
.range(..=up_to)
.map(|(t, v)| (*t, v.clone()))
.enumerate()
.take_while(|(idx, _)| *idx < max_elements)
.map(|(_, (t, v))| (*t, v.clone()))
.collect())
}
fn load_first_block_number(&self) -> Result<Option<BlockNumber>, Error> {