mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-26 02:08:10 -07:00
global: snapshot
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{StoredF32, StoredF64};
|
||||
use brk_types::{BasisPointsSigned32, StoredF64};
|
||||
use vecdb::Exit;
|
||||
|
||||
use super::super::activity;
|
||||
@@ -14,15 +14,15 @@ impl Vecs {
|
||||
activity: &activity::Vecs,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.cointime_adj_inflation_rate.height.compute_transform2(
|
||||
self.cointime_adj_inflation_rate.bps.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&activity.activity_to_vaultedness_ratio.height,
|
||||
&supply.inflation.height,
|
||||
|(h, ratio, inflation, ..)| (h, StoredF32::from((*ratio) * f64::from(*inflation))),
|
||||
&supply.inflation_rate.bps.height,
|
||||
|(h, ratio, inflation, ..)| (h, BasisPointsSigned32::from((*ratio) * f64::from(inflation))),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_btc_velocity
|
||||
self.cointime_adj_tx_velocity_btc
|
||||
.height
|
||||
.compute_transform2(
|
||||
starting_indexes.height,
|
||||
@@ -32,7 +32,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_usd_velocity
|
||||
self.cointime_adj_tx_velocity_usd
|
||||
.height
|
||||
.compute_transform2(
|
||||
starting_indexes.height,
|
||||
|
||||
@@ -3,26 +3,29 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedFromHeight};
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{Bps32ToFloat, Bps32ToPercent, ComputedFromHeight, PercentFromHeight},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
cointime_adj_inflation_rate: ComputedFromHeight::forced_import(
|
||||
cointime_adj_inflation_rate: PercentFromHeight::forced_import::<Bps32ToFloat, Bps32ToPercent>(
|
||||
db,
|
||||
"cointime_adj_inflation_rate",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_btc_velocity: ComputedFromHeight::forced_import(
|
||||
cointime_adj_tx_velocity_btc: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_btc_velocity",
|
||||
"cointime_adj_tx_velocity_btc",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_usd_velocity: ComputedFromHeight::forced_import(
|
||||
cointime_adj_tx_velocity_usd: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_usd_velocity",
|
||||
"cointime_adj_tx_velocity_usd",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{StoredF32, StoredF64};
|
||||
use brk_types::{BasisPointsSigned32, StoredF64};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedFromHeight;
|
||||
use crate::internal::{ComputedFromHeight, PercentFromHeight};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub cointime_adj_inflation_rate: ComputedFromHeight<StoredF32, M>,
|
||||
pub cointime_adj_tx_btc_velocity: ComputedFromHeight<StoredF64, M>,
|
||||
pub cointime_adj_tx_usd_velocity: ComputedFromHeight<StoredF64, M>,
|
||||
pub cointime_adj_inflation_rate: PercentFromHeight<BasisPointsSigned32, M>,
|
||||
pub cointime_adj_tx_velocity_btc: ComputedFromHeight<StoredF64, M>,
|
||||
pub cointime_adj_tx_velocity_usd: ComputedFromHeight<StoredF64, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user