mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-03 23:33:40 -07:00
global: snapshot
This commit is contained in:
@@ -35,28 +35,28 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.hash_rate_1w_sma.height.compute_rolling_average(
|
||||
self.hash_rate_sma_1w.height.compute_rolling_average(
|
||||
starting_indexes.height,
|
||||
&count_vecs.height_1w_ago,
|
||||
&self.hash_rate.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.hash_rate_1m_sma.height.compute_rolling_average(
|
||||
self.hash_rate_sma_1m.height.compute_rolling_average(
|
||||
starting_indexes.height,
|
||||
&count_vecs.height_1m_ago,
|
||||
&self.hash_rate.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.hash_rate_2m_sma.height.compute_rolling_average(
|
||||
self.hash_rate_sma_2m.height.compute_rolling_average(
|
||||
starting_indexes.height,
|
||||
&count_vecs.height_2m_ago,
|
||||
&self.hash_rate.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.hash_rate_1y_sma.height.compute_rolling_average(
|
||||
self.hash_rate_sma_1y.height.compute_rolling_average(
|
||||
starting_indexes.height,
|
||||
&count_vecs.height_1y_ago,
|
||||
&self.hash_rate.height,
|
||||
@@ -69,7 +69,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.hash_rate_drawdown.height.compute_drawdown(
|
||||
self.hash_rate_drawdown.compute_drawdown(
|
||||
starting_indexes.height,
|
||||
&self.hash_rate.height,
|
||||
&self.hash_rate_ath.height,
|
||||
|
||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::ComputedFromHeight,
|
||||
internal::{Bps16ToFloat, Bps16ToPercent, ComputedFromHeight, PercentFromHeight},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -19,27 +19,27 @@ impl Vecs {
|
||||
|
||||
Ok(Self {
|
||||
hash_rate: ComputedFromHeight::forced_import(db, "hash_rate", version + v5, indexes)?,
|
||||
hash_rate_1w_sma: ComputedFromHeight::forced_import(
|
||||
hash_rate_sma_1w: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_1w_sma",
|
||||
"hash_rate_sma_1w",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_1m_sma: ComputedFromHeight::forced_import(
|
||||
hash_rate_sma_1m: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_1m_sma",
|
||||
"hash_rate_sma_1m",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_2m_sma: ComputedFromHeight::forced_import(
|
||||
hash_rate_sma_2m: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_2m_sma",
|
||||
"hash_rate_sma_2m",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_1y_sma: ComputedFromHeight::forced_import(
|
||||
hash_rate_sma_1y: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"hash_rate_1y_sma",
|
||||
"hash_rate_sma_1y",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
@@ -49,7 +49,7 @@ impl Vecs {
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
hash_rate_drawdown: ComputedFromHeight::forced_import(
|
||||
hash_rate_drawdown: PercentFromHeight::forced_import::<Bps16ToFloat, Bps16ToPercent>(
|
||||
db,
|
||||
"hash_rate_drawdown",
|
||||
version,
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{StoredF32, StoredF64};
|
||||
use brk_types::{BasisPointsSigned16, StoredF32, StoredF64};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedFromHeight;
|
||||
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>,
|
||||
pub hash_rate_1w_sma: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_1m_sma: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_2m_sma: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_1y_sma: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_sma_1w: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_sma_1m: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_sma_2m: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_sma_1y: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_ath: ComputedFromHeight<StoredF64, M>,
|
||||
pub hash_rate_drawdown: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_rate_drawdown: PercentFromHeight<BasisPointsSigned16, M>,
|
||||
pub hash_price_ths: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_price_ths_min: ComputedFromHeight<StoredF32, M>,
|
||||
pub hash_price_phs: ComputedFromHeight<StoredF32, M>,
|
||||
|
||||
Reference in New Issue
Block a user