mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-07 17:18:13 -07:00
global: big snapshot
This commit is contained in:
@@ -4,27 +4,24 @@ use vecdb::Exit;
|
||||
|
||||
use super::super::activity;
|
||||
use super::Vecs;
|
||||
use crate::{blocks, distribution, prices};
|
||||
use crate::{distribution, prices};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
starting_indexes: &Indexes,
|
||||
prices: &prices::Vecs,
|
||||
blocks: &blocks::Vecs,
|
||||
distribution: &distribution::Vecs,
|
||||
activity: &activity::Vecs,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let window_starts = blocks.lookback.window_starts();
|
||||
|
||||
let all_metrics = &distribution.utxo_cohorts.all.metrics;
|
||||
let coinblocks_destroyed = &distribution.coinblocks_destroyed;
|
||||
let coindays_destroyed = &all_metrics.activity.coindays_destroyed;
|
||||
let circulating_supply = &all_metrics.supply.total.btc.height;
|
||||
|
||||
self.destroyed
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&prices.spot.usd.height,
|
||||
@@ -35,7 +32,7 @@ impl Vecs {
|
||||
})?;
|
||||
|
||||
self.created
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&prices.spot.usd.height,
|
||||
@@ -46,7 +43,7 @@ impl Vecs {
|
||||
})?;
|
||||
|
||||
self.stored
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&prices.spot.usd.height,
|
||||
@@ -60,7 +57,7 @@ impl Vecs {
|
||||
// Supply-adjusted to account for growing supply over time
|
||||
// This is a key input for Reserve Risk / HODL Bank calculation
|
||||
self.vocdd
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_transform3(
|
||||
starting_indexes.height,
|
||||
&prices.spot.usd.height,
|
||||
|
||||
@@ -3,38 +3,46 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedPerBlockCumulativeSum};
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{CachedWindowStarts, ComputedPerBlockCumulativeWithSums},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(
|
||||
db: &Database,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
cached_starts: &CachedWindowStarts,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
destroyed: ComputedPerBlockCumulativeSum::forced_import(
|
||||
destroyed: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"cointime_value_destroyed",
|
||||
version,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
created: ComputedPerBlockCumulativeSum::forced_import(
|
||||
created: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"cointime_value_created",
|
||||
version,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
stored: ComputedPerBlockCumulativeSum::forced_import(
|
||||
stored: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"cointime_value_stored",
|
||||
version,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
vocdd: ComputedPerBlockCumulativeSum::forced_import(
|
||||
vocdd: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"vocdd",
|
||||
version + Version::ONE,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ use brk_traversable::Traversable;
|
||||
use brk_types::StoredF64;
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedPerBlockCumulativeSum;
|
||||
use crate::internal::ComputedPerBlockCumulativeWithSums;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub destroyed: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub created: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub stored: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub vocdd: ComputedPerBlockCumulativeSum<StoredF64, M>,
|
||||
pub destroyed: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
|
||||
pub created: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
|
||||
pub stored: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
|
||||
pub vocdd: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user