mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: v0.2 incoming
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{BasisPointsSigned32, Height, Indexes, StoredF32, StoredI64, StoredU32, StoredU64, Version};
|
||||
use brk_types::{
|
||||
BasisPointsSigned32, Height, Indexes, StoredF32, StoredI64, StoredU32, StoredU64, Version,
|
||||
};
|
||||
use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec};
|
||||
|
||||
use crate::{
|
||||
@@ -8,7 +10,7 @@ use crate::{
|
||||
metrics::ImportConfig,
|
||||
state::{CohortState, CostBasisOps, RealizedOps},
|
||||
},
|
||||
internal::{PerBlock, PerBlockCumulativeRolling, PerBlockWithDeltas, RatioU32U64F32},
|
||||
internal::{PerBlock, PerBlockCumulativeRolling, PerBlockWithDeltas, RatioU64F32},
|
||||
};
|
||||
|
||||
/// Base output metrics: utxo_count + delta.
|
||||
@@ -32,12 +34,14 @@ impl OutputsBase {
|
||||
cfg.cached_starts,
|
||||
)?,
|
||||
spent_count: cfg.import("spent_utxo_count", v1)?,
|
||||
spending_rate: cfg.import("spending_rate", v1)?,
|
||||
spending_rate: cfg.import("spending_rate", Version::TWO)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_len(&self) -> usize {
|
||||
self.unspent_count.height.len()
|
||||
self.unspent_count
|
||||
.height
|
||||
.len()
|
||||
.min(self.spent_count.block.len())
|
||||
}
|
||||
|
||||
@@ -69,9 +73,9 @@ impl OutputsBase {
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.spending_rate
|
||||
.compute_binary::<StoredU32, StoredU64, RatioU32U64F32>(
|
||||
.compute_binary::<StoredU64, StoredU64, RatioU64F32>(
|
||||
max_from,
|
||||
&self.spent_count.block,
|
||||
&self.spent_count.sum.0._1y.height,
|
||||
all_utxo_count,
|
||||
exit,
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ pub use derived::{
|
||||
pub use ratio::{
|
||||
RatioCentsBp32, RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RatioDiffCentsBps32,
|
||||
RatioDiffDollarsBps32, RatioDiffF32Bps32, RatioDollarsBp16, RatioDollarsBp32,
|
||||
RatioDollarsBps32, RatioSatsBp16, RatioU32U64F32, RatioU64Bp16,
|
||||
RatioDollarsBps32, RatioSatsBp16, RatioU64Bp16, RatioU64F32,
|
||||
};
|
||||
pub use specialized::{
|
||||
BlockCountTarget1m, BlockCountTarget1w, BlockCountTarget1y, BlockCountTarget24h,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_types::{
|
||||
BasisPoints16, BasisPoints32, BasisPointsSigned32, Cents, CentsSigned, Dollars, Sats, StoredF32,
|
||||
StoredU32, StoredU64,
|
||||
StoredU64,
|
||||
};
|
||||
use vecdb::BinaryTransform;
|
||||
|
||||
@@ -112,11 +112,11 @@ impl BinaryTransform<Dollars, Dollars, BasisPoints32> for RatioDollarsBp32 {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RatioU32U64F32;
|
||||
pub struct RatioU64F32;
|
||||
|
||||
impl BinaryTransform<StoredU32, StoredU64, StoredF32> for RatioU32U64F32 {
|
||||
impl BinaryTransform<StoredU64, StoredU64, StoredF32> for RatioU64F32 {
|
||||
#[inline(always)]
|
||||
fn apply(numerator: StoredU32, denominator: StoredU64) -> StoredF32 {
|
||||
fn apply(numerator: StoredU64, denominator: StoredU64) -> StoredF32 {
|
||||
if *denominator > 0 {
|
||||
StoredF32::from(*numerator as f64 / *denominator as f64)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user