mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
computer: renames
This commit is contained in:
@@ -4,7 +4,7 @@ use brk_types::{Height, StoredU64, Version};
|
||||
use vecdb::{Database, IterableCloneableVec, VecIndex};
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::{ComputedDerivedBlockFull, LazyComputedBlockFull}};
|
||||
use crate::{indexes, internal::{ComputedDerivedBlockFull, BlockFullLazyHeight}};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(
|
||||
@@ -14,7 +14,7 @@ impl Vecs {
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
vbytes: LazyComputedBlockFull::forced_import_with_init(
|
||||
vbytes: BlockFullLazyHeight::forced_import_with_init(
|
||||
db,
|
||||
"block_vbytes",
|
||||
version,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{StoredU64, Weight};
|
||||
|
||||
use crate::internal::{ComputedDerivedBlockFull, LazyComputedBlockFull};
|
||||
use crate::internal::{ComputedDerivedBlockFull, BlockFullLazyHeight};
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub vbytes: LazyComputedBlockFull<StoredU64, Weight>,
|
||||
pub vbytes: BlockFullLazyHeight<StoredU64, Weight>,
|
||||
pub size: ComputedDerivedBlockFull<StoredU64>,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Lazy binary height + stored derived SumCum.
|
||||
//! BlockSumCumLazyHeight - block sum+cumulative with lazy height transform.
|
||||
//!
|
||||
//! Use this when you need:
|
||||
//! - Lazy height (binary transform from two sources)
|
||||
@@ -16,14 +16,14 @@ use crate::{indexes, ComputeIndexes};
|
||||
|
||||
use crate::internal::{ComputedVecValue, ComputedDerivedBlockSumCum, NumericValue};
|
||||
|
||||
/// Lazy binary height + stored derived block SumCum.
|
||||
/// Block sum+cumulative with lazy binary height transform + computed derived indexes.
|
||||
///
|
||||
/// Height is a lazy binary transform (e.g., mask × source, or price × sats).
|
||||
/// Cumulative and dateindex are stored (computed from lazy height).
|
||||
/// Coarser periods are lazy lookups.
|
||||
#[derive(Clone, Deref, DerefMut, Traversable)]
|
||||
#[traversable(merge)]
|
||||
pub struct LazyComputedBlockSumCum<T, S1T = T, S2T = T>
|
||||
pub struct BlockSumCumLazyHeight<T, S1T = T, S2T = T>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd + JsonSchema,
|
||||
S1T: ComputedVecValue,
|
||||
@@ -38,7 +38,7 @@ where
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
|
||||
impl<T, S1T, S2T> LazyComputedBlockSumCum<T, S1T, S2T>
|
||||
impl<T, S1T, S2T> BlockSumCumLazyHeight<T, S1T, S2T>
|
||||
where
|
||||
T: NumericValue + JsonSchema,
|
||||
S1T: ComputedVecValue + JsonSchema,
|
||||
@@ -9,7 +9,7 @@ mod height_date_last;
|
||||
mod height_date_max;
|
||||
mod height_date_min;
|
||||
mod last;
|
||||
mod lazy_sum_cum;
|
||||
mod lazy_height_sum_cum;
|
||||
mod sum;
|
||||
mod sum_cum;
|
||||
|
||||
@@ -20,6 +20,6 @@ pub use height_date_last::*;
|
||||
pub use height_date_max::*;
|
||||
pub use height_date_min::*;
|
||||
pub use last::*;
|
||||
pub use lazy_sum_cum::*;
|
||||
pub use lazy_height_sum_cum::*;
|
||||
pub use sum::*;
|
||||
pub use sum_cum::*;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! LazyComputedBlockFull - lazy height + ComputedDerivedBlockFull.
|
||||
//! BlockFullLazyHeight - block full with lazy height transform.
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
@@ -14,10 +14,10 @@ use crate::{
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
|
||||
/// Lazy height transform + stored/computed derived indexes.
|
||||
/// Block full aggregation with lazy height transform + computed derived indexes.
|
||||
#[derive(Clone, Deref, DerefMut, Traversable)]
|
||||
#[traversable(merge)]
|
||||
pub struct LazyComputedBlockFull<T, S = T>
|
||||
pub struct BlockFullLazyHeight<T, S = T>
|
||||
where
|
||||
T: ComputedVecValue + PartialOrd + JsonSchema,
|
||||
S: ComputedVecValue,
|
||||
@@ -29,7 +29,7 @@ where
|
||||
pub rest: ComputedDerivedBlockFull<T>,
|
||||
}
|
||||
|
||||
impl<T, S> LazyComputedBlockFull<T, S>
|
||||
impl<T, S> BlockFullLazyHeight<T, S>
|
||||
where
|
||||
T: NumericValue + JsonSchema,
|
||||
S: ComputedVecValue + JsonSchema,
|
||||
@@ -2,10 +2,10 @@ mod binary_full;
|
||||
mod binary_last;
|
||||
mod binary_sum;
|
||||
mod binary_sum_cum;
|
||||
mod computed_full;
|
||||
mod distribution;
|
||||
mod full;
|
||||
mod last;
|
||||
mod lazy_height_full;
|
||||
mod sum;
|
||||
mod sum_cum;
|
||||
|
||||
@@ -13,9 +13,9 @@ pub use binary_full::*;
|
||||
pub use binary_last::*;
|
||||
pub use binary_sum::*;
|
||||
pub use binary_sum_cum::*;
|
||||
pub use computed_full::*;
|
||||
pub use distribution::*;
|
||||
pub use full::*;
|
||||
pub use last::*;
|
||||
pub use lazy_height_full::*;
|
||||
pub use sum::*;
|
||||
pub use sum_cum::*;
|
||||
|
||||
@@ -14,7 +14,7 @@ use vecdb::{Database, Exit, IterableCloneableVec, LazyVecFrom2};
|
||||
use crate::{
|
||||
ComputeIndexes, indexes,
|
||||
internal::{
|
||||
ClosePriceTimesSats, ComputedBlockSumCum, LazyBlockSumCum, LazyComputedBlockSumCum,
|
||||
ClosePriceTimesSats, ComputedBlockSumCum, LazyBlockSumCum, BlockSumCumLazyHeight,
|
||||
SatsToBitcoin,
|
||||
},
|
||||
price,
|
||||
@@ -29,7 +29,7 @@ use crate::{
|
||||
pub struct LazyComputedValueBlockSumCum {
|
||||
pub sats: ComputedBlockSumCum<Sats>,
|
||||
pub bitcoin: LazyBlockSumCum<Bitcoin, Sats>,
|
||||
pub dollars: Option<LazyComputedBlockSumCum<Dollars, Close<Dollars>, Sats>>,
|
||||
pub dollars: Option<BlockSumCumLazyHeight<Dollars, Close<Dollars>, Sats>>,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
@@ -61,7 +61,7 @@ impl LazyComputedValueBlockSumCum {
|
||||
sats.height.boxed_clone(),
|
||||
);
|
||||
|
||||
Some(LazyComputedBlockSumCum::forced_import(
|
||||
Some(BlockSumCumLazyHeight::forced_import(
|
||||
db,
|
||||
&format!("{name}_usd"),
|
||||
v,
|
||||
|
||||
@@ -13,7 +13,7 @@ use vecdb::{
|
||||
use crate::{
|
||||
ComputeIndexes, indexes,
|
||||
internal::{
|
||||
ClosePriceTimesSats, ComputedVecValue, LazyBlockSumCum, LazyComputedBlockSumCum,
|
||||
ClosePriceTimesSats, ComputedVecValue, LazyBlockSumCum, BlockSumCumLazyHeight,
|
||||
SatsToBitcoin,
|
||||
},
|
||||
price,
|
||||
@@ -30,9 +30,9 @@ where
|
||||
S1T: ComputedVecValue + JsonSchema,
|
||||
S2T: ComputedVecValue + JsonSchema,
|
||||
{
|
||||
pub sats: LazyComputedBlockSumCum<Sats, S1T, S2T>,
|
||||
pub sats: BlockSumCumLazyHeight<Sats, S1T, S2T>,
|
||||
pub bitcoin: LazyBlockSumCum<Bitcoin, Sats>,
|
||||
pub dollars: Option<LazyComputedBlockSumCum<Dollars, Close<Dollars>, Sats>>,
|
||||
pub dollars: Option<BlockSumCumLazyHeight<Dollars, Close<Dollars>, Sats>>,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
@@ -57,7 +57,7 @@ where
|
||||
let v = version + VERSION;
|
||||
|
||||
let sats_height = LazyVecFrom2::transformed::<F>(name, v, source1, source2);
|
||||
let sats = LazyComputedBlockSumCum::forced_import(db, name, v, indexes, sats_height)?;
|
||||
let sats = BlockSumCumLazyHeight::forced_import(db, name, v, indexes, sats_height)?;
|
||||
|
||||
let bitcoin = LazyBlockSumCum::from_derived::<SatsToBitcoin>(
|
||||
&format!("{name}_btc"),
|
||||
@@ -74,7 +74,7 @@ where
|
||||
sats.height.boxed_clone(),
|
||||
);
|
||||
|
||||
Some(LazyComputedBlockSumCum::forced_import(
|
||||
Some(BlockSumCumLazyHeight::forced_import(
|
||||
db,
|
||||
&format!("{name}_usd"),
|
||||
v,
|
||||
|
||||
@@ -8,7 +8,7 @@ use vecdb::{Database, Exit, IterableBoxedVec, IterableCloneableVec, IterableVec,
|
||||
use crate::{
|
||||
ComputeIndexes, indexes,
|
||||
internal::{
|
||||
ClosePriceTimesSats, ComputedDerivedBlockSumCum, LazyBlockSumCum, LazyComputedBlockSumCum,
|
||||
ClosePriceTimesSats, ComputedDerivedBlockSumCum, LazyBlockSumCum, BlockSumCumLazyHeight,
|
||||
SatsToBitcoin,
|
||||
},
|
||||
price,
|
||||
@@ -19,7 +19,7 @@ use crate::{
|
||||
pub struct DerivedValueBlockSumCum {
|
||||
pub sats: ComputedDerivedBlockSumCum<Sats>,
|
||||
pub bitcoin: LazyBlockSumCum<Bitcoin, Sats>,
|
||||
pub dollars: Option<LazyComputedBlockSumCum<Dollars, Close<Dollars>, Sats>>,
|
||||
pub dollars: Option<BlockSumCumLazyHeight<Dollars, Close<Dollars>, Sats>>,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::ZERO;
|
||||
@@ -58,7 +58,7 @@ impl DerivedValueBlockSumCum {
|
||||
sats_source.boxed_clone(),
|
||||
);
|
||||
|
||||
Some(LazyComputedBlockSumCum::forced_import(
|
||||
Some(BlockSumCumLazyHeight::forced_import(
|
||||
db,
|
||||
&format!("{name}_usd"),
|
||||
v,
|
||||
|
||||
Reference in New Issue
Block a user