global: snapshot

This commit is contained in:
nym21
2026-03-04 17:10:15 +01:00
parent 891f0dad9e
commit 9e23de4ba1
313 changed files with 9087 additions and 4918 deletions

View File

@@ -5,10 +5,7 @@ use vecdb::Database;
use super::Vecs;
use crate::{
indexes,
internal::{
ComputedFromHeight,
PercentFromHeight,
},
internal::{ComputedFromHeight, PercentFromHeight},
};
impl Vecs {

View File

@@ -4,7 +4,6 @@ use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedFromHeight, PercentFromHeight};
/// Mining-related metrics: hash rate, hash price, hash value
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub hash_rate: ComputedFromHeight<StoredF64, M>,

View File

@@ -1,11 +1,12 @@
use std::path::Path;
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::Version;
use vecdb::{Database, PAGE_SIZE};
use crate::indexes;
use crate::{
indexes,
internal::{finalize_db, open_db},
};
use super::{HashrateVecs, RewardsVecs, Vecs};
@@ -15,9 +16,7 @@ impl Vecs {
parent_version: Version,
indexes: &indexes::Vecs,
) -> Result<Self> {
let db = Database::open(&parent_path.join(super::DB_NAME))?;
db.set_min_len(PAGE_SIZE * 50_000_000)?;
let db = open_db(parent_path, super::DB_NAME, 50_000_000)?;
let version = parent_version;
let rewards = RewardsVecs::forced_import(&db, version, indexes)?;
@@ -28,14 +27,7 @@ impl Vecs {
rewards,
hashrate,
};
this.db.retain_regions(
this.iter_any_exportable()
.flat_map(|v| v.region_names())
.collect(),
)?;
this.db.compact()?;
finalize_db(&this.db, &this)?;
Ok(this)
}
}

View File

@@ -122,12 +122,13 @@ impl Vecs {
)?;
// All-time cumulative fee dominance
self.fee_dominance.compute_binary::<Sats, Sats, RatioSatsBp16>(
starting_indexes.height,
&self.fees.cumulative.sats.height,
&self.coinbase.cumulative.sats.height,
exit,
)?;
self.fee_dominance
.compute_binary::<Sats, Sats, RatioSatsBp16>(
starting_indexes.height,
&self.fees.cumulative.sats.height,
&self.coinbase.cumulative.sats.height,
exit,
)?;
// Rolling fee dominance = sum(fees) / sum(coinbase)
for ((fee_dom, fees_w), coinbase_w) in self
@@ -146,12 +147,13 @@ impl Vecs {
}
// All-time cumulative subsidy dominance
self.subsidy_dominance.compute_binary::<Sats, Sats, RatioSatsBp16>(
starting_indexes.height,
&self.subsidy.cumulative.sats.height,
&self.coinbase.cumulative.sats.height,
exit,
)?;
self.subsidy_dominance
.compute_binary::<Sats, Sats, RatioSatsBp16>(
starting_indexes.height,
&self.subsidy.cumulative.sats.height,
&self.coinbase.cumulative.sats.height,
exit,
)?;
// Rolling subsidy dominance = 1 - fee_dominance
for (sub_dom, fee_dom) in self

View File

@@ -6,8 +6,8 @@ use super::Vecs;
use crate::{
indexes,
internal::{
FiatFromHeight, PercentFromHeight, PercentRollingWindows,
ValueFromHeightFull, ValueFromHeightCumulativeSum,
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulativeSum,
ValueFromHeightFull,
},
};
@@ -27,12 +27,7 @@ impl Vecs {
version,
indexes,
)?,
fee_dominance: PercentFromHeight::forced_import(
db,
"fee_dominance",
version,
indexes,
)?,
fee_dominance: PercentFromHeight::forced_import(db, "fee_dominance", version, indexes)?,
fee_dominance_rolling: PercentRollingWindows::forced_import(
db,
"fee_dominance",
@@ -51,12 +46,7 @@ impl Vecs {
version,
indexes,
)?,
subsidy_sma_1y: FiatFromHeight::forced_import(
db,
"subsidy_sma_1y",
version,
indexes,
)?,
subsidy_sma_1y: FiatFromHeight::forced_import(db, "subsidy_sma_1y", version, indexes)?,
})
}
}

View File

@@ -3,11 +3,10 @@ use brk_types::{BasisPoints16, Cents};
use vecdb::{Rw, StorageMode};
use crate::internal::{
FiatFromHeight, PercentFromHeight, PercentRollingWindows,
ValueFromHeightFull, ValueFromHeightCumulativeSum,
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulativeSum,
ValueFromHeightFull,
};
/// Coinbase/subsidy/rewards metrics
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub coinbase: ValueFromHeightFull<M>,