mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 14:49:58 -07:00
global: snapshot
This commit is contained in:
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::ComputedFromHeightLast,
|
||||
internal::ComputedFromHeight,
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -18,98 +18,98 @@ impl Vecs {
|
||||
let v5 = Version::new(5);
|
||||
|
||||
Ok(Self {
|
||||
hash_rate: ComputedFromHeightLast::forced_import(db, "hash_rate", version + v5, indexes)?,
|
||||
hash_rate_1w_sma: ComputedFromHeightLast::forced_import(
|
||||
hash_rate: ComputedFromHeight::forced_import(db, "hash_rate", version + v5, indexes)?,
|
||||
hash_rate_1w_sma: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_1w_sma",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_1m_sma: ComputedFromHeightLast::forced_import(
|
||||
hash_rate_1m_sma: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_1m_sma",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_2m_sma: ComputedFromHeightLast::forced_import(
|
||||
hash_rate_2m_sma: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_2m_sma",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_1y_sma: ComputedFromHeightLast::forced_import(
|
||||
hash_rate_1y_sma: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_1y_sma",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_ath: ComputedFromHeightLast::forced_import(
|
||||
hash_rate_ath: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_ath",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_drawdown: ComputedFromHeightLast::forced_import(
|
||||
hash_rate_drawdown: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_drawdown",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_price_ths: ComputedFromHeightLast::forced_import(
|
||||
hash_price_ths: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_price_ths",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_price_ths_min: ComputedFromHeightLast::forced_import(
|
||||
hash_price_ths_min: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_price_ths_min",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_price_phs: ComputedFromHeightLast::forced_import(
|
||||
hash_price_phs: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_price_phs",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_price_phs_min: ComputedFromHeightLast::forced_import(
|
||||
hash_price_phs_min: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_price_phs_min",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_price_rebound: ComputedFromHeightLast::forced_import(
|
||||
hash_price_rebound: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_price_rebound",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_value_ths: ComputedFromHeightLast::forced_import(
|
||||
hash_value_ths: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_value_ths",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_value_ths_min: ComputedFromHeightLast::forced_import(
|
||||
hash_value_ths_min: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_value_ths_min",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_value_phs: ComputedFromHeightLast::forced_import(
|
||||
hash_value_phs: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_value_phs",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_value_phs_min: ComputedFromHeightLast::forced_import(
|
||||
hash_value_phs_min: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_value_phs_min",
|
||||
version + v4,
|
||||
indexes,
|
||||
)?,
|
||||
hash_value_rebound: ComputedFromHeightLast::forced_import(
|
||||
hash_value_rebound: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_value_rebound",
|
||||
version + v4,
|
||||
|
||||
@@ -2,26 +2,26 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{StoredF32, StoredF64};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedFromHeightLast;
|
||||
use crate::internal::ComputedFromHeight;
|
||||
|
||||
/// Mining-related metrics: hash rate, hash price, hash value
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub hash_rate: ComputedFromHeightLast<StoredF64, M>,
|
||||
pub hash_rate_1w_sma: ComputedFromHeightLast<StoredF64, M>,
|
||||
pub hash_rate_1m_sma: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_rate_2m_sma: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_rate_1y_sma: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_rate_ath: ComputedFromHeightLast<StoredF64, M>,
|
||||
pub hash_rate_drawdown: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_price_ths: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_price_ths_min: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_price_phs: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_price_phs_min: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_price_rebound: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_value_ths: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_value_ths_min: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_value_phs: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_value_phs_min: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_value_rebound: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub hash_rate: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_1w_sma: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_1m_sma: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_rate_2m_sma: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_rate_1y_sma: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_rate_ath: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_drawdown: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_price_ths: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_price_ths_min: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_price_phs: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_price_phs_min: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_price_rebound: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_value_ths: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_value_ths_min: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_value_phs: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_value_phs_min: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_value_rebound: ComputedFromHeight<StoredF32, M>,
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{
|
||||
ComputedFromHeightLast, FiatFromHeightLast, ValueFromHeightFull,
|
||||
ValueFromHeightSumCumulative,
|
||||
ComputedFromHeight, FiatFromHeight, ValueFromHeightFull,
|
||||
ValueFromHeightCumulativeSum,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -21,73 +21,73 @@ impl Vecs {
|
||||
coinbase: ValueFromHeightFull::forced_import(db, "coinbase", version, indexes)?,
|
||||
subsidy: ValueFromHeightFull::forced_import(db, "subsidy", version, indexes)?,
|
||||
fees: ValueFromHeightFull::forced_import(db, "fees", version, indexes)?,
|
||||
unclaimed_rewards: ValueFromHeightSumCumulative::forced_import(
|
||||
unclaimed_rewards: ValueFromHeightCumulativeSum::forced_import(
|
||||
db,
|
||||
"unclaimed_rewards",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance: ComputedFromHeightLast::forced_import(
|
||||
fee_dominance: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_24h: ComputedFromHeightLast::forced_import(
|
||||
fee_dominance_24h: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance_24h",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_7d: ComputedFromHeightLast::forced_import(
|
||||
fee_dominance_7d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance_7d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_30d: ComputedFromHeightLast::forced_import(
|
||||
fee_dominance_30d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance_30d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
fee_dominance_1y: ComputedFromHeightLast::forced_import(
|
||||
fee_dominance_1y: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"fee_dominance_1y",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance: ComputedFromHeightLast::forced_import(
|
||||
subsidy_dominance: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_24h: ComputedFromHeightLast::forced_import(
|
||||
subsidy_dominance_24h: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_24h",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_7d: ComputedFromHeightLast::forced_import(
|
||||
subsidy_dominance_7d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_7d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_30d: ComputedFromHeightLast::forced_import(
|
||||
subsidy_dominance_30d: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_30d",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_dominance_1y: ComputedFromHeightLast::forced_import(
|
||||
subsidy_dominance_1y: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_dominance_1y",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
subsidy_usd_1y_sma: FiatFromHeightLast::forced_import(
|
||||
subsidy_usd_1y_sma: FiatFromHeight::forced_import(
|
||||
db,
|
||||
"subsidy_usd_1y_sma",
|
||||
version,
|
||||
|
||||
@@ -3,8 +3,8 @@ use brk_types::{Cents, StoredF32};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{
|
||||
ComputedFromHeightLast, FiatFromHeightLast, ValueFromHeightFull,
|
||||
ValueFromHeightSumCumulative,
|
||||
ComputedFromHeight, FiatFromHeight, ValueFromHeightFull,
|
||||
ValueFromHeightCumulativeSum,
|
||||
};
|
||||
|
||||
/// Coinbase/subsidy/rewards metrics
|
||||
@@ -13,16 +13,16 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub coinbase: ValueFromHeightFull<M>,
|
||||
pub subsidy: ValueFromHeightFull<M>,
|
||||
pub fees: ValueFromHeightFull<M>,
|
||||
pub unclaimed_rewards: ValueFromHeightSumCumulative<M>,
|
||||
pub fee_dominance: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub fee_dominance_24h: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub fee_dominance_7d: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub fee_dominance_30d: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub fee_dominance_1y: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub subsidy_dominance: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub subsidy_dominance_24h: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub subsidy_dominance_7d: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub subsidy_dominance_30d: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub subsidy_dominance_1y: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub subsidy_usd_1y_sma: FiatFromHeightLast<Cents, M>,
|
||||
pub unclaimed_rewards: ValueFromHeightCumulativeSum<M>,
|
||||
pub fee_dominance: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_24h: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_7d: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_30d: ComputedFromHeight<StoredF32, M>,
|
||||
pub fee_dominance_1y: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_24h: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_7d: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_30d: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_dominance_1y: ComputedFromHeight<StoredF32, M>,
|
||||
pub subsidy_usd_1y_sma: FiatFromHeight<Cents, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user