mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -44,11 +44,10 @@ impl Vecs {
|
||||
|
||||
self.coinblocks_stored
|
||||
.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
vec.compute_transform2(
|
||||
vec.compute_subtract(
|
||||
starting_indexes.height,
|
||||
&self.coinblocks_created.height,
|
||||
&coinblocks_destroyed.height,
|
||||
|(i, created, destroyed, ..)| (i, created.checked_sub(destroyed).unwrap()),
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{BasisPointsSigned32, StoredF64};
|
||||
use brk_types::BasisPointsSigned32;
|
||||
use vecdb::Exit;
|
||||
|
||||
use super::super::activity;
|
||||
@@ -16,29 +16,27 @@ impl Vecs {
|
||||
) -> Result<()> {
|
||||
self.cointime_adj_inflation_rate.bps.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&activity.activity_to_vaultedness_ratio.height,
|
||||
&activity.liveliness.height,
|
||||
&supply.inflation_rate.bps.height,
|
||||
|(h, ratio, inflation, ..)| (h, BasisPointsSigned32::from((*ratio) * f64::from(inflation))),
|
||||
|(h, liveliness, inflation, ..)| (h, BasisPointsSigned32::from(f64::from(liveliness) * f64::from(inflation))),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_velocity_btc
|
||||
.height
|
||||
.compute_transform2(
|
||||
.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&activity.activity_to_vaultedness_ratio.height,
|
||||
&supply.velocity.btc.height,
|
||||
|(h, ratio, vel, ..)| (h, StoredF64::from(*ratio * *vel)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_velocity_usd
|
||||
.height
|
||||
.compute_transform2(
|
||||
.compute_multiply(
|
||||
starting_indexes.height,
|
||||
&activity.activity_to_vaultedness_ratio.height,
|
||||
&supply.velocity.usd.height,
|
||||
|(h, ratio, vel, ..)| (h, StoredF64::from(*ratio * *vel)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{Bps32ToFloat, Bps32ToPercent, ComputedFromHeight, PercentFromHeight},
|
||||
internal::{ComputedFromHeight, PercentFromHeight},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
cointime_adj_inflation_rate: PercentFromHeight::forced_import::<Bps32ToFloat, Bps32ToPercent>(
|
||||
cointime_adj_inflation_rate: PercentFromHeight::forced_import_bps32(
|
||||
db,
|
||||
"cointime_adj_inflation_rate",
|
||||
version,
|
||||
|
||||
@@ -48,23 +48,17 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.vaulted_cap.cents.height.compute_transform2(
|
||||
self.vaulted_cap.cents.height.compute_multiply(
|
||||
starting_indexes.height,
|
||||
realized_cap_cents,
|
||||
&activity.vaultedness.height,
|
||||
|(i, cap, vaultedness, ..)| {
|
||||
(i, Cents::from(f64::from(cap) / f64::from(vaultedness)))
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.active_cap.cents.height.compute_transform2(
|
||||
self.active_cap.cents.height.compute_multiply(
|
||||
starting_indexes.height,
|
||||
realized_cap_cents,
|
||||
&activity.liveliness.height,
|
||||
|(i, cap, liveliness, ..)| {
|
||||
(i, Cents::from(f64::from(cap) * f64::from(liveliness)))
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -54,13 +54,10 @@ impl Vecs {
|
||||
&self.vaulted_price.cents.height,
|
||||
)?;
|
||||
|
||||
self.active_price.cents.height.compute_transform2(
|
||||
self.active_price.cents.height.compute_multiply(
|
||||
starting_indexes.height,
|
||||
realized_price,
|
||||
&activity.liveliness.height,
|
||||
|(i, price, liveliness, ..)| {
|
||||
(i, Cents::from(f64::from(price) * f64::from(liveliness)))
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user