mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-04 15:53:40 -07:00
global: big snapshot
This commit is contained in:
@@ -3,23 +3,20 @@ use brk_types::{Bitcoin, CheckedSub, Indexes, StoredF64};
|
||||
use vecdb::Exit;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{blocks, distribution};
|
||||
use crate::distribution;
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
starting_indexes: &Indexes,
|
||||
blocks: &blocks::Vecs,
|
||||
distribution: &distribution::Vecs,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let window_starts = blocks.lookback.window_starts();
|
||||
|
||||
let all_metrics = &distribution.utxo_cohorts.all.metrics;
|
||||
let circulating_supply = &all_metrics.supply.total.sats.height;
|
||||
|
||||
self.coinblocks_created
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_transform(
|
||||
starting_indexes.height,
|
||||
circulating_supply,
|
||||
@@ -30,7 +27,7 @@ impl Vecs {
|
||||
})?;
|
||||
|
||||
self.coinblocks_stored
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_subtract(
|
||||
starting_indexes.height,
|
||||
&self.coinblocks_created.raw.height,
|
||||
|
||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{ComputedPerBlock, ComputedPerBlockCumulativeSum},
|
||||
internal::{CachedWindowStarts, ComputedPerBlock, ComputedPerBlockCumulativeWithSums},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -13,19 +13,22 @@ impl Vecs {
|
||||
db: &Database,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
cached_starts: &CachedWindowStarts,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
coinblocks_created: ComputedPerBlockCumulativeSum::forced_import(
|
||||
coinblocks_created: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"coinblocks_created",
|
||||
version,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
coinblocks_stored: ComputedPerBlockCumulativeSum::forced_import(
|
||||
coinblocks_stored: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"coinblocks_stored",
|
||||
version,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
liveliness: ComputedPerBlock::forced_import(db, "liveliness", version, indexes)?,
|
||||
vaultedness: ComputedPerBlock::forced_import(db, "vaultedness", version, indexes)?,
|
||||
|
||||
@@ -2,12 +2,12 @@ use brk_traversable::Traversable;
|
||||
use brk_types::StoredF64;
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{ComputedPerBlock, ComputedPerBlockCumulativeSum};
|
||||
use crate::internal::{ComputedPerBlock, ComputedPerBlockCumulativeWithSums};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub coinblocks_created: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub coinblocks_stored: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub coinblocks_created: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
|
||||
pub coinblocks_stored: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
|
||||
pub liveliness: ComputedPerBlock<StoredF64, M>,
|
||||
pub vaultedness: ComputedPerBlock<StoredF64, M>,
|
||||
pub ratio: ComputedPerBlock<StoredF64, M>,
|
||||
|
||||
Reference in New Issue
Block a user