global: snapshot

This commit is contained in:
nym21
2026-03-01 22:41:25 +01:00
parent 159c983a3f
commit 7cb1bfa667
119 changed files with 1241 additions and 1182 deletions
@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::ValueFromHeightSumCumulative};
use crate::{indexes, internal::ValueFromHeightCumulativeSum};
impl Vecs {
pub(crate) fn forced_import(
@@ -12,13 +12,13 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
opreturn: ValueFromHeightSumCumulative::forced_import(
opreturn: ValueFromHeightCumulativeSum::forced_import(
db,
"opreturn_supply",
version,
indexes,
)?,
unspendable: ValueFromHeightSumCumulative::forced_import(
unspendable: ValueFromHeightCumulativeSum::forced_import(
db,
"unspendable_supply",
version,
@@ -1,11 +1,11 @@
use brk_traversable::Traversable;
use vecdb::{Rw, StorageMode};
use crate::internal::ValueFromHeightSumCumulative;
use crate::internal::ValueFromHeightCumulativeSum;
/// Burned/unspendable supply metrics
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub opreturn: ValueFromHeightSumCumulative<M>,
pub unspendable: ValueFromHeightSumCumulative<M>,
pub opreturn: ValueFromHeightCumulativeSum<M>,
pub unspendable: ValueFromHeightCumulativeSum<M>,
}
+8 -7
View File
@@ -9,7 +9,7 @@ use super::Vecs;
use crate::{
distribution, indexes,
internal::{
ComputedFromHeightLast, DollarsIdentity, LazyFromHeightLast, LazyValueFromHeightLast,
CentsIdentity, ComputedFromHeight, DollarsIdentity, LazyFromHeight, LazyValueFromHeight,
SatsIdentity, SatsToBitcoin,
},
};
@@ -30,9 +30,10 @@ impl Vecs {
let supply_metrics = &distribution.utxo_cohorts.all.metrics.supply;
// Circulating supply - lazy refs to distribution
let circulating = LazyValueFromHeightLast::from_block_source::<
let circulating = LazyValueFromHeight::from_block_source::<
SatsIdentity,
SatsToBitcoin,
CentsIdentity,
DollarsIdentity,
>("circulating_supply", &supply_metrics.total, version);
@@ -41,33 +42,33 @@ impl Vecs {
// Inflation rate
let inflation =
ComputedFromHeightLast::forced_import(&db, "inflation_rate", version, indexes)?;
ComputedFromHeight::forced_import(&db, "inflation_rate", version, indexes)?;
// Velocity
let velocity = super::velocity::Vecs::forced_import(&db, version, indexes)?;
// Market cap - lazy identity from distribution supply in USD
let market_cap = LazyFromHeightLast::from_lazy::<DollarsIdentity, Cents>(
let market_cap = LazyFromHeight::from_lazy::<DollarsIdentity, Cents>(
"market_cap",
version,
&supply_metrics.total.usd,
);
// Growth rates
let market_cap_growth_rate = ComputedFromHeightLast::forced_import(
let market_cap_growth_rate = ComputedFromHeight::forced_import(
&db,
"market_cap_growth_rate",
version + Version::ONE,
indexes,
)?;
let realized_cap_growth_rate = ComputedFromHeightLast::forced_import(
let realized_cap_growth_rate = ComputedFromHeight::forced_import(
&db,
"realized_cap_growth_rate",
version + Version::ONE,
indexes,
)?;
let cap_growth_rate_diff =
ComputedFromHeightLast::forced_import(&db, "cap_growth_rate_diff", version, indexes)?;
ComputedFromHeight::forced_import(&db, "cap_growth_rate_diff", version, indexes)?;
let this = Self {
db,
+7 -7
View File
@@ -4,7 +4,7 @@ use vecdb::{Database, Rw, StorageMode};
use super::{burned, velocity};
use crate::internal::{
ComputedFromHeightLast, LazyFromHeightLast, LazyValueFromHeightLast,
ComputedFromHeight, LazyFromHeight, LazyValueFromHeight,
};
#[derive(Traversable)]
@@ -12,12 +12,12 @@ pub struct Vecs<M: StorageMode = Rw> {
#[traversable(skip)]
pub(crate) db: Database,
pub circulating: LazyValueFromHeightLast,
pub circulating: LazyValueFromHeight,
pub burned: burned::Vecs<M>,
pub inflation: ComputedFromHeightLast<StoredF32, M>,
pub inflation: ComputedFromHeight<StoredF32, M>,
pub velocity: velocity::Vecs<M>,
pub market_cap: LazyFromHeightLast<Dollars>,
pub market_cap_growth_rate: ComputedFromHeightLast<StoredF32, M>,
pub realized_cap_growth_rate: ComputedFromHeightLast<StoredF32, M>,
pub cap_growth_rate_diff: ComputedFromHeightLast<StoredF32, M>,
pub market_cap: LazyFromHeight<Dollars>,
pub market_cap_growth_rate: ComputedFromHeight<StoredF32, M>,
pub realized_cap_growth_rate: ComputedFromHeight<StoredF32, M>,
pub cap_growth_rate_diff: ComputedFromHeight<StoredF32, M>,
}
@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::ComputedFromHeightLast};
use crate::{indexes, internal::ComputedFromHeight};
impl Vecs {
pub(crate) fn forced_import(
@@ -12,8 +12,8 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
btc: ComputedFromHeightLast::forced_import(db, "btc_velocity", version, indexes)?,
usd: ComputedFromHeightLast::forced_import(db, "usd_velocity", version, indexes)?,
btc: ComputedFromHeight::forced_import(db, "btc_velocity", version, indexes)?,
usd: ComputedFromHeight::forced_import(db, "usd_velocity", version, indexes)?,
})
}
}
@@ -2,11 +2,11 @@ use brk_traversable::Traversable;
use brk_types::StoredF64;
use vecdb::{Rw, StorageMode};
use crate::internal::ComputedFromHeightLast;
use crate::internal::ComputedFromHeight;
/// Velocity metrics (annualized volume / circulating supply)
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub btc: ComputedFromHeightLast<StoredF64, M>,
pub usd: ComputedFromHeightLast<StoredF64, M>,
pub btc: ComputedFromHeight<StoredF64, M>,
pub usd: ComputedFromHeight<StoredF64, M>,
}