mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-25 01:38:12 -07:00
computer: snapshot
This commit is contained in:
@@ -10,12 +10,12 @@ impl Vecs {
|
||||
&mut self,
|
||||
scripts: &scripts::Vecs,
|
||||
mining: &mining::Vecs,
|
||||
count_vecs: &blocks::CountVecs,
|
||||
lookback: &blocks::LookbackVecs,
|
||||
prices: &prices::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let window_starts = count_vecs.window_starts();
|
||||
let window_starts = lookback.window_starts();
|
||||
|
||||
// 1. Compute opreturn supply - copy per-block opreturn values from scripts
|
||||
self.opreturn.compute(
|
||||
|
||||
@@ -3,7 +3,7 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ValueFromHeightCumulativeSum};
|
||||
use crate::{indexes, internal::AmountFromHeightCumulativeSum};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(
|
||||
@@ -12,13 +12,13 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
opreturn: ValueFromHeightCumulativeSum::forced_import(
|
||||
opreturn: AmountFromHeightCumulativeSum::forced_import(
|
||||
db,
|
||||
"opreturn_supply",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
unspendable: ValueFromHeightCumulativeSum::forced_import(
|
||||
unspendable: AmountFromHeightCumulativeSum::forced_import(
|
||||
db,
|
||||
"unspendable_supply",
|
||||
version,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use brk_traversable::Traversable;
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ValueFromHeightCumulativeSum;
|
||||
use crate::internal::AmountFromHeightCumulativeSum;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub opreturn: ValueFromHeightCumulativeSum<M>,
|
||||
pub unspendable: ValueFromHeightCumulativeSum<M>,
|
||||
pub opreturn: AmountFromHeightCumulativeSum<M>,
|
||||
pub unspendable: AmountFromHeightCumulativeSum<M>,
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ impl Vecs {
|
||||
self.burned.compute(
|
||||
scripts,
|
||||
mining,
|
||||
&blocks.count,
|
||||
&blocks.lookback,
|
||||
prices,
|
||||
starting_indexes,
|
||||
exit,
|
||||
@@ -35,7 +35,7 @@ impl Vecs {
|
||||
.height
|
||||
.compute_rolling_ratio_change(
|
||||
starting_indexes.height,
|
||||
&blocks.count.height_1y_ago,
|
||||
&blocks.lookback.height_1y_ago,
|
||||
&circulating_supply.height,
|
||||
exit,
|
||||
)?;
|
||||
@@ -45,7 +45,7 @@ impl Vecs {
|
||||
.compute(blocks, transactions, distribution, starting_indexes, exit)?;
|
||||
|
||||
// 4. Compute market cap delta (change + rate across 4 windows)
|
||||
let window_starts = blocks.count.window_starts();
|
||||
let window_starts = blocks.lookback.window_starts();
|
||||
|
||||
self.market_cap_delta.compute(
|
||||
starting_indexes.height,
|
||||
|
||||
@@ -6,7 +6,7 @@ use brk_types::{Cents, Dollars, Sats, Version};
|
||||
use crate::{
|
||||
distribution, indexes,
|
||||
internal::{
|
||||
FiatRollingDelta, Identity, LazyFiatFromHeight, LazyValueFromHeight, PercentFromHeight,
|
||||
FiatRollingDelta, Identity, LazyFiatFromHeight, LazyAmountFromHeight, PercentFromHeight,
|
||||
RollingWindows, SatsToBitcoin, finalize_db, open_db,
|
||||
},
|
||||
};
|
||||
@@ -28,7 +28,7 @@ impl Vecs {
|
||||
let supply_metrics = &distribution.utxo_cohorts.all.metrics.supply;
|
||||
|
||||
// Circulating supply - lazy refs to distribution
|
||||
let circulating = LazyValueFromHeight::from_block_source::<
|
||||
let circulating = LazyAmountFromHeight::from_block_source::<
|
||||
Identity<Sats>,
|
||||
SatsToBitcoin,
|
||||
Identity<Cents>,
|
||||
|
||||
@@ -4,7 +4,7 @@ use vecdb::{Database, Rw, StorageMode};
|
||||
|
||||
use super::{burned, velocity};
|
||||
use crate::internal::{
|
||||
FiatRollingDelta, LazyFiatFromHeight, LazyValueFromHeight, PercentFromHeight, RollingWindows,
|
||||
FiatRollingDelta, LazyFiatFromHeight, LazyAmountFromHeight, PercentFromHeight, RollingWindows,
|
||||
};
|
||||
|
||||
#[derive(Traversable)]
|
||||
@@ -12,7 +12,7 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
#[traversable(skip)]
|
||||
pub(crate) db: Database,
|
||||
|
||||
pub circulating: LazyValueFromHeight,
|
||||
pub circulating: LazyAmountFromHeight,
|
||||
pub burned: burned::Vecs<M>,
|
||||
pub inflation_rate: PercentFromHeight<BasisPointsSigned32, M>,
|
||||
pub velocity: velocity::Vecs<M>,
|
||||
|
||||
@@ -20,7 +20,7 @@ impl Vecs {
|
||||
// BTC velocity at height level
|
||||
self.btc.height.compute_rolling_ratio(
|
||||
starting_indexes.height,
|
||||
&blocks.count.height_1y_ago,
|
||||
&blocks.lookback.height_1y_ago,
|
||||
&transactions.volume.sent_sum.sats,
|
||||
&circulating_supply.sats.height,
|
||||
exit,
|
||||
@@ -29,7 +29,7 @@ impl Vecs {
|
||||
// USD velocity at height level
|
||||
self.usd.height.compute_rolling_ratio(
|
||||
starting_indexes.height,
|
||||
&blocks.count.height_1y_ago,
|
||||
&blocks.lookback.height_1y_ago,
|
||||
&transactions.volume.sent_sum.usd,
|
||||
&circulating_supply.usd.height,
|
||||
exit,
|
||||
|
||||
Reference in New Issue
Block a user