global: snapshot part 6

This commit is contained in:
nym21
2026-03-20 17:02:32 +01:00
parent 17106f887a
commit f683adba13
34 changed files with 197 additions and 204 deletions
@@ -17,20 +17,20 @@ impl Vecs {
+ indexer.vecs.transactions.txid.version();
for vec in [
&mut self.v1.base.height,
&mut self.v2.base.height,
&mut self.v3.base.height,
&mut self.v1.block.height,
&mut self.v2.block.height,
&mut self.v3.block.height,
] {
vec.validate_and_truncate(dep_version, starting_indexes.height)?;
}
let skip = self
.v1
.base
.block
.height
.len()
.min(self.v2.base.height.len())
.min(self.v3.base.height.len());
.min(self.v2.block.height.len())
.min(self.v3.block.height.len());
let first_tx_index = &indexer.vecs.transactions.first_tx_index;
let end = first_tx_index.len();
@@ -39,9 +39,9 @@ impl Vecs {
}
// Truncate all 3 to skip, then push (no per-element bounds checks).
self.v1.base.height.truncate_if_needed_at(skip)?;
self.v2.base.height.truncate_if_needed_at(skip)?;
self.v3.base.height.truncate_if_needed_at(skip)?;
self.v1.block.height.truncate_if_needed_at(skip)?;
self.v2.block.height.truncate_if_needed_at(skip)?;
self.v3.block.height.truncate_if_needed_at(skip)?;
// Single cursor over tx_version — scanned once for all 3 version counts.
let mut cursor = indexer.vecs.transactions.tx_version.cursor();
@@ -69,23 +69,23 @@ impl Vecs {
}
}
self.v1.base.height.push(StoredU64::from(c1 as u64));
self.v2.base.height.push(StoredU64::from(c2 as u64));
self.v3.base.height.push(StoredU64::from(c3 as u64));
self.v1.block.height.push(StoredU64::from(c1 as u64));
self.v2.block.height.push(StoredU64::from(c2 as u64));
self.v3.block.height.push(StoredU64::from(c3 as u64));
if self.v1.base.height.batch_limit_reached() {
if self.v1.block.height.batch_limit_reached() {
let _lock = exit.lock();
self.v1.base.height.write()?;
self.v2.base.height.write()?;
self.v3.base.height.write()?;
self.v1.block.height.write()?;
self.v2.block.height.write()?;
self.v3.block.height.write()?;
}
}
{
let _lock = exit.lock();
self.v1.base.height.write()?;
self.v2.base.height.write()?;
self.v3.base.height.write()?;
self.v1.block.height.write()?;
self.v2.block.height.write()?;
self.v3.block.height.write()?;
}
// Derive cumulative + sums from base