mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
global: snapshot
This commit is contained in:
@@ -30,14 +30,14 @@ impl Vecs {
|
||||
self.tx_velocity_btc.height.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&activity.ratio.height,
|
||||
&supply.velocity.btc.height,
|
||||
&supply.velocity.native.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.tx_velocity_usd.height.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&activity.ratio.height,
|
||||
&supply.velocity.usd.height,
|
||||
&supply.velocity.fiat.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF32, StoredF64, Version};
|
||||
use brk_types::{Bitcoin, Height, Indexes, StoredF32, StoredF64, Version};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode};
|
||||
use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, Rw, StorageMode};
|
||||
|
||||
use crate::internal::{PerBlock, Identity, LazyPerBlock};
|
||||
use crate::internal::{Identity, LazyPerBlock, PerBlock};
|
||||
|
||||
use crate::distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}};
|
||||
|
||||
@@ -20,7 +20,6 @@ pub struct ActivityFull<M: StorageMode = Rw> {
|
||||
pub coinyears_destroyed: LazyPerBlock<StoredF64, StoredF64>,
|
||||
|
||||
pub dormancy: PerBlock<StoredF32, M>,
|
||||
pub velocity: PerBlock<StoredF32, M>,
|
||||
}
|
||||
|
||||
impl ActivityFull {
|
||||
@@ -39,7 +38,6 @@ impl ActivityFull {
|
||||
inner,
|
||||
coinyears_destroyed,
|
||||
dormancy: cfg.import("dormancy", v1)?,
|
||||
velocity: cfg.import("velocity", v1)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -58,7 +56,6 @@ impl ActivityFull {
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
let mut vecs = self.inner.collect_vecs_mut();
|
||||
vecs.push(&mut self.dormancy.height);
|
||||
vecs.push(&mut self.velocity.height);
|
||||
vecs
|
||||
}
|
||||
|
||||
@@ -83,7 +80,6 @@ impl ActivityFull {
|
||||
pub(crate) fn compute_rest_part2(
|
||||
&mut self,
|
||||
starting_indexes: &Indexes,
|
||||
supply_total_sats: &impl ReadableVec<Height, Sats>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.dormancy.height.compute_transform2(
|
||||
@@ -101,21 +97,6 @@ impl ActivityFull {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.velocity.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.inner.sent.base.height,
|
||||
supply_total_sats,
|
||||
|(i, sent_sats, supply_sats, ..)| {
|
||||
let supply = supply_sats.as_u128() as f64;
|
||||
if supply == 0.0 {
|
||||
(i, StoredF32::from(0.0f32))
|
||||
} else {
|
||||
(i, StoredF32::from((sent_sats.as_u128() as f64 / supply) as f32))
|
||||
}
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,6 @@ impl AllCohortMetrics {
|
||||
|
||||
self.activity.compute_rest_part2(
|
||||
starting_indexes,
|
||||
&self.supply.total.sats.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -125,7 +125,6 @@ impl ExtendedCohortMetrics {
|
||||
|
||||
self.activity.compute_rest_part2(
|
||||
starting_indexes,
|
||||
&self.supply.total.sats.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ use crate::{
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct AdjustedSopr<M: StorageMode = Rw> {
|
||||
pub ratio: RollingWindows<StoredF64, M>,
|
||||
pub value_created: PerBlockCumulativeWithSums<Cents, Cents, M>,
|
||||
pub value_destroyed: PerBlockCumulativeWithSums<Cents, Cents, M>,
|
||||
pub ratio: RollingWindows<StoredF64, M>,
|
||||
}
|
||||
|
||||
impl AdjustedSopr {
|
||||
pub(crate) fn forced_import(cfg: &ImportConfig) -> Result<Self> {
|
||||
Ok(Self {
|
||||
ratio: cfg.import("asopr", Version::ONE)?,
|
||||
value_created: cfg.import("adj_value_created", Version::ONE)?,
|
||||
value_destroyed: cfg.import("adj_value_destroyed", Version::ONE)?,
|
||||
ratio: cfg.import("asopr", Version::ONE)?,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ impl Vecs {
|
||||
// velocity = rolling_1y_sum(volume) / circulating_supply
|
||||
let circulating_supply = &distribution.utxo_cohorts.all.metrics.supply.total;
|
||||
|
||||
// BTC velocity at height level
|
||||
self.btc.height.compute_rolling_ratio(
|
||||
// Native velocity at height level
|
||||
self.native.height.compute_rolling_ratio(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback._1y,
|
||||
&transactions.volume.sent_sum.base.sats.height,
|
||||
@@ -26,8 +26,8 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// USD velocity at height level
|
||||
self.usd.height.compute_rolling_ratio(
|
||||
// Fiat velocity at height level
|
||||
self.fiat.height.compute_rolling_ratio(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback._1y,
|
||||
&transactions.volume.sent_sum.base.usd.height,
|
||||
|
||||
@@ -12,8 +12,8 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
btc: PerBlock::forced_import(db, "velocity_btc", version, indexes)?,
|
||||
usd: PerBlock::forced_import(db, "velocity_usd", version, indexes)?,
|
||||
native: PerBlock::forced_import(db, "velocity", version, indexes)?,
|
||||
fiat: PerBlock::forced_import(db, "velocity_fiat", version, indexes)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ use crate::internal::PerBlock;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub btc: PerBlock<StoredF64, M>,
|
||||
pub usd: PerBlock<StoredF64, M>,
|
||||
pub native: PerBlock<StoredF64, M>,
|
||||
pub fiat: PerBlock<StoredF64, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user