mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 23:59:58 -07:00
computer: snapshot
This commit is contained in:
@@ -22,7 +22,7 @@ impl Vecs {
|
||||
self.rewards.compute(
|
||||
indexer,
|
||||
indexes,
|
||||
&blocks.count,
|
||||
&blocks.lookback,
|
||||
&transactions.fees,
|
||||
prices,
|
||||
starting_indexes,
|
||||
@@ -31,6 +31,7 @@ impl Vecs {
|
||||
|
||||
self.hashrate.compute(
|
||||
&blocks.count,
|
||||
&blocks.lookback,
|
||||
&blocks.difficulty,
|
||||
&self.rewards.coinbase.sum._24h.sats.height,
|
||||
&self.rewards.coinbase.sum._24h.usd.height,
|
||||
|
||||
@@ -9,9 +9,11 @@ use crate::{
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
count_vecs: &blocks::CountVecs,
|
||||
lookback: &blocks::LookbackVecs,
|
||||
difficulty_vecs: &blocks::DifficultyVecs,
|
||||
coinbase_sats_24h_sum: &impl ReadableVec<Height, Sats>,
|
||||
coinbase_usd_24h_sum: &impl ReadableVec<Height, Dollars>,
|
||||
@@ -20,7 +22,7 @@ impl Vecs {
|
||||
) -> Result<()> {
|
||||
self.hash_rate.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&count_vecs.block_count_sum._24h.height,
|
||||
&count_vecs.block_count.sum._24h.height,
|
||||
&difficulty_vecs.as_hash.height,
|
||||
|(i, block_count_sum, difficulty_as_hash, ..)| {
|
||||
(
|
||||
@@ -36,10 +38,10 @@ impl Vecs {
|
||||
|
||||
let hash_rate = &self.hash_rate.height;
|
||||
for (sma, window) in [
|
||||
(&mut self.hash_rate_sma_1w.height, &count_vecs.height_1w_ago),
|
||||
(&mut self.hash_rate_sma_1m.height, &count_vecs.height_1m_ago),
|
||||
(&mut self.hash_rate_sma_2m.height, &count_vecs.height_2m_ago),
|
||||
(&mut self.hash_rate_sma_1y.height, &count_vecs.height_1y_ago),
|
||||
(&mut self.hash_rate_sma_1w.height, &lookback.height_1w_ago),
|
||||
(&mut self.hash_rate_sma_1m.height, &lookback.height_1m_ago),
|
||||
(&mut self.hash_rate_sma_2m.height, &lookback.height_2m_ago),
|
||||
(&mut self.hash_rate_sma_1y.height, &lookback.height_1y_ago),
|
||||
] {
|
||||
sma.compute_rolling_average(starting_indexes.height, window, hash_rate, exit)?;
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ impl Vecs {
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
count_vecs: &blocks::CountVecs,
|
||||
lookback: &blocks::LookbackVecs,
|
||||
transactions_fees: &transactions::FeesVecs,
|
||||
prices: &prices::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let window_starts = count_vecs.window_starts();
|
||||
let window_starts = lookback.window_starts();
|
||||
|
||||
self.coinbase.compute(
|
||||
starting_indexes.height,
|
||||
@@ -163,7 +163,7 @@ impl Vecs {
|
||||
|
||||
self.subsidy_sma_1y.cents.height.compute_rolling_average(
|
||||
starting_indexes.height,
|
||||
&count_vecs.height_1y_ago,
|
||||
&lookback.height_1y_ago,
|
||||
&self.subsidy.base.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -6,8 +6,8 @@ use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{
|
||||
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulative,
|
||||
ValueFromHeightCumulativeSum, ValueFromHeightFull,
|
||||
AmountFromHeightCumulative, AmountFromHeightCumulativeSum, AmountFromHeightFull,
|
||||
FiatFromHeight, PercentFromHeight, PercentRollingWindows,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -18,10 +18,12 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
coinbase: ValueFromHeightCumulativeSum::forced_import(db, "coinbase", version, indexes)?,
|
||||
subsidy: ValueFromHeightCumulative::forced_import(db, "subsidy", version, indexes)?,
|
||||
fees: ValueFromHeightFull::forced_import(db, "fees", version, indexes)?,
|
||||
unclaimed_rewards: ValueFromHeightCumulativeSum::forced_import(
|
||||
coinbase: AmountFromHeightCumulativeSum::forced_import(
|
||||
db, "coinbase", version, indexes,
|
||||
)?,
|
||||
subsidy: AmountFromHeightCumulative::forced_import(db, "subsidy", version, indexes)?,
|
||||
fees: AmountFromHeightFull::forced_import(db, "fees", version, indexes)?,
|
||||
unclaimed_rewards: AmountFromHeightCumulativeSum::forced_import(
|
||||
db,
|
||||
"unclaimed_rewards",
|
||||
version,
|
||||
|
||||
@@ -3,16 +3,16 @@ use brk_types::{BasisPoints16, Cents};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{
|
||||
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulative,
|
||||
ValueFromHeightCumulativeSum, ValueFromHeightFull,
|
||||
AmountFromHeightCumulative, AmountFromHeightCumulativeSum, AmountFromHeightFull,
|
||||
FiatFromHeight, PercentFromHeight, PercentRollingWindows,
|
||||
};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub coinbase: ValueFromHeightCumulativeSum<M>,
|
||||
pub subsidy: ValueFromHeightCumulative<M>,
|
||||
pub fees: ValueFromHeightFull<M>,
|
||||
pub unclaimed_rewards: ValueFromHeightCumulativeSum<M>,
|
||||
pub coinbase: AmountFromHeightCumulativeSum<M>,
|
||||
pub subsidy: AmountFromHeightCumulative<M>,
|
||||
pub fees: AmountFromHeightFull<M>,
|
||||
pub unclaimed_rewards: AmountFromHeightCumulativeSum<M>,
|
||||
pub fee_dominance: PercentFromHeight<BasisPoints16, M>,
|
||||
pub fee_dominance_rolling: PercentRollingWindows<BasisPoints16, M>,
|
||||
pub subsidy_dominance: PercentFromHeight<BasisPoints16, M>,
|
||||
|
||||
Reference in New Issue
Block a user