mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 23:59:58 -07:00
global: big snapshot
This commit is contained in:
@@ -3,7 +3,7 @@ use brk_types::{Bitcoin, CheckedSub, StoredF64};
|
||||
use vecdb::{Exit, TypedVecIterator};
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{distribution, indexes, ComputeIndexes};
|
||||
use crate::{ComputeIndexes, distribution, indexes};
|
||||
|
||||
impl Vecs {
|
||||
pub fn compute(
|
||||
@@ -13,9 +13,16 @@ impl Vecs {
|
||||
distribution: &distribution::Vecs,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let circulating_supply = &distribution.utxo_cohorts.all.metrics.supply.height_to_supply;
|
||||
let circulating_supply = &distribution
|
||||
.utxo_cohorts
|
||||
.all
|
||||
.metrics
|
||||
.supply
|
||||
.supply
|
||||
.sats
|
||||
.height;
|
||||
|
||||
self.indexes_to_coinblocks_created
|
||||
self.coinblocks_created
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_transform(
|
||||
starting_indexes.height,
|
||||
@@ -26,21 +33,19 @@ impl Vecs {
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
let indexes_to_coinblocks_destroyed = &distribution
|
||||
let coinblocks_destroyed = &distribution
|
||||
.utxo_cohorts
|
||||
.all
|
||||
.metrics
|
||||
.activity
|
||||
.indexes_to_coinblocks_destroyed;
|
||||
.coinblocks_destroyed;
|
||||
|
||||
self.indexes_to_coinblocks_stored
|
||||
self.coinblocks_stored
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
let mut coinblocks_destroyed_iter = indexes_to_coinblocks_destroyed
|
||||
.height
|
||||
.into_iter();
|
||||
let mut coinblocks_destroyed_iter = coinblocks_destroyed.height.into_iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.indexes_to_coinblocks_created.height,
|
||||
&self.coinblocks_created.height,
|
||||
|(i, created, ..)| {
|
||||
let destroyed = coinblocks_destroyed_iter.get_unwrap(i);
|
||||
(i, created.checked_sub(destroyed).unwrap())
|
||||
@@ -50,42 +55,38 @@ impl Vecs {
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
self.indexes_to_liveliness
|
||||
self.liveliness
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_divide(
|
||||
starting_indexes.height,
|
||||
indexes_to_coinblocks_destroyed.height_cumulative.inner(),
|
||||
self.indexes_to_coinblocks_created.height_cumulative.inner(),
|
||||
coinblocks_destroyed.height_cumulative.inner(),
|
||||
self.coinblocks_created.height_cumulative.inner(),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
self.indexes_to_vaultedness
|
||||
self.vaultedness
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.indexes_to_liveliness.height,
|
||||
&self.liveliness.height,
|
||||
|(i, v, ..)| (i, StoredF64::from(1.0).checked_sub(v).unwrap()),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
self.indexes_to_activity_to_vaultedness_ratio.compute_all(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec| {
|
||||
self.activity_to_vaultedness_ratio
|
||||
.compute_all(indexes, starting_indexes, exit, |vec| {
|
||||
vec.compute_divide(
|
||||
starting_indexes.height,
|
||||
&self.indexes_to_liveliness.height,
|
||||
&self.indexes_to_vaultedness.height,
|
||||
&self.liveliness.height,
|
||||
&self.vaultedness.height,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user