global: adding support for safe lengths

This commit is contained in:
nym21
2026-05-06 15:33:07 +02:00
parent da7671744f
commit 086bfd9938
177 changed files with 2445 additions and 2049 deletions
@@ -1,5 +1,6 @@
use brk_error::Result;
use brk_types::{Bitcoin, Indexes, StoredF64};
use brk_indexer::Indexer;
use brk_types::{Bitcoin, StoredF64};
use vecdb::Exit;
use super::Vecs;
@@ -8,17 +9,18 @@ use crate::distribution;
impl Vecs {
pub(crate) fn compute(
&mut self,
starting_indexes: &Indexes,
indexer: &Indexer,
distribution: &distribution::Vecs,
exit: &Exit,
) -> Result<()> {
let starting_height = indexer.safe_lengths().height;
let all_metrics = &distribution.utxo_cohorts.all.metrics;
let circulating_supply = &all_metrics.supply.total.sats.height;
self.coinblocks_created
.compute(starting_indexes.height, exit, |vec| {
.compute(starting_height, exit, |vec| {
vec.compute_transform(
starting_indexes.height,
starting_height,
circulating_supply,
|(i, v, ..)| (i, StoredF64::from(Bitcoin::from(v))),
exit,
@@ -27,9 +29,9 @@ impl Vecs {
})?;
self.coinblocks_stored
.compute(starting_indexes.height, exit, |vec| {
.compute(starting_height, exit, |vec| {
vec.compute_subtract(
starting_indexes.height,
starting_height,
&self.coinblocks_created.block,
&distribution.coinblocks_destroyed.block,
exit,
@@ -38,14 +40,14 @@ impl Vecs {
})?;
self.liveliness.height.compute_divide(
starting_indexes.height,
starting_height,
&distribution.coinblocks_destroyed.cumulative.height,
&self.coinblocks_created.cumulative.height,
exit,
)?;
self.ratio.height.compute_divide(
starting_indexes.height,
starting_height,
&self.liveliness.height,
&self.vaultedness.height,
exit,