mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-11 02:58:14 -07:00
global: snapshot
This commit is contained in:
@@ -5,7 +5,7 @@ use vecdb::{EagerVec, Exit, PcoVec, TypedVecIterator};
|
||||
|
||||
use super::super::time;
|
||||
use super::Vecs;
|
||||
use crate::{ComputeIndexes, indexes, internal::ComputedBlockLast};
|
||||
use crate::{ComputeIndexes, indexes, internal::ComputedFromHeightLast};
|
||||
|
||||
impl Vecs {
|
||||
pub fn compute(
|
||||
@@ -104,7 +104,7 @@ impl Vecs {
|
||||
get_field: F,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> &mut ComputedBlockLast<StoredU32>,
|
||||
F: FnOnce(&mut Self) -> &mut ComputedFromHeightLast<StoredU32>,
|
||||
{
|
||||
get_field(self).compute_all(indexes, starting_indexes, exit, |v| {
|
||||
v.compute_transform(
|
||||
|
||||
@@ -10,13 +10,13 @@ use crate::{
|
||||
TARGET_BLOCKS_PER_YEAR,
|
||||
},
|
||||
indexes,
|
||||
internal::{ComputedBlockLast, ComputedBlockSumCum, LazyPeriodVecs},
|
||||
internal::{ComputedFromHeightLast, ComputedFromHeightSumCum, LazyFromDate},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
block_count_target: LazyPeriodVecs::new(
|
||||
block_count_target: LazyFromDate::new(
|
||||
"block_count_target",
|
||||
version,
|
||||
indexes,
|
||||
@@ -28,30 +28,30 @@ impl Vecs {
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_YEAR)),
|
||||
|_, _| Some(StoredU64::from(TARGET_BLOCKS_PER_DECADE)),
|
||||
),
|
||||
block_count: ComputedBlockSumCum::forced_import(db, "block_count", version, indexes)?,
|
||||
block_count: ComputedFromHeightSumCum::forced_import(db, "block_count", version, indexes)?,
|
||||
_24h_start: ImportableVec::forced_import(db, "24h_start", version)?,
|
||||
_1w_start: ImportableVec::forced_import(db, "1w_start", version)?,
|
||||
_1m_start: ImportableVec::forced_import(db, "1m_start", version)?,
|
||||
_1y_start: ImportableVec::forced_import(db, "1y_start", version)?,
|
||||
_24h_block_count: ComputedBlockLast::forced_import(
|
||||
_24h_block_count: ComputedFromHeightLast::forced_import(
|
||||
db,
|
||||
"24h_block_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
_1w_block_count: ComputedBlockLast::forced_import(
|
||||
_1w_block_count: ComputedFromHeightLast::forced_import(
|
||||
db,
|
||||
"1w_block_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
_1m_block_count: ComputedBlockLast::forced_import(
|
||||
_1m_block_count: ComputedFromHeightLast::forced_import(
|
||||
db,
|
||||
"1m_block_count",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
_1y_block_count: ComputedBlockLast::forced_import(
|
||||
_1y_block_count: ComputedFromHeightLast::forced_import(
|
||||
db,
|
||||
"1y_block_count",
|
||||
version,
|
||||
|
||||
@@ -2,20 +2,20 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{Height, StoredU32, StoredU64};
|
||||
use vecdb::{EagerVec, PcoVec};
|
||||
|
||||
use crate::internal::{ComputedBlockLast, ComputedBlockSumCum, LazyPeriodVecs};
|
||||
use crate::internal::{ComputedFromHeightLast, ComputedFromHeightSumCum, LazyFromDate};
|
||||
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub block_count_target: LazyPeriodVecs<StoredU64>,
|
||||
pub block_count: ComputedBlockSumCum<StoredU32>,
|
||||
pub block_count_target: LazyFromDate<StoredU64>,
|
||||
pub block_count: ComputedFromHeightSumCum<StoredU32>,
|
||||
// Rolling window starts (height-indexed only, no date aggregation needed)
|
||||
pub _24h_start: EagerVec<PcoVec<Height, Height>>,
|
||||
pub _1w_start: EagerVec<PcoVec<Height, Height>>,
|
||||
pub _1m_start: EagerVec<PcoVec<Height, Height>>,
|
||||
pub _1y_start: EagerVec<PcoVec<Height, Height>>,
|
||||
// Rolling window block counts
|
||||
pub _24h_block_count: ComputedBlockLast<StoredU32>,
|
||||
pub _1w_block_count: ComputedBlockLast<StoredU32>,
|
||||
pub _1m_block_count: ComputedBlockLast<StoredU32>,
|
||||
pub _1y_block_count: ComputedBlockLast<StoredU32>,
|
||||
pub _24h_block_count: ComputedFromHeightLast<StoredU32>,
|
||||
pub _1w_block_count: ComputedFromHeightLast<StoredU32>,
|
||||
pub _1m_block_count: ComputedFromHeightLast<StoredU32>,
|
||||
pub _1y_block_count: ComputedFromHeightLast<StoredU32>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user