diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 268962e12..af166f56c 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -969,6 +969,55 @@ impl PricePercentilesPattern { } } +/// Pattern struct for repeated tree structure. +pub struct ActivePriceRatioPattern { + pub ratio: Indexes, + pub ratio_1m_sma: Indexes, + pub ratio_1w_sma: Indexes, + pub ratio_1y_sd: Ratio1ySdPattern, + pub ratio_2y_sd: Ratio1ySdPattern, + pub ratio_4y_sd: Ratio1ySdPattern, + pub ratio_pct1: Indexes, + pub ratio_pct1_usd: Indexes, + pub ratio_pct2: Indexes, + pub ratio_pct2_usd: Indexes, + pub ratio_pct5: Indexes, + pub ratio_pct5_usd: Indexes, + pub ratio_pct95: Indexes, + pub ratio_pct95_usd: Indexes, + pub ratio_pct98: Indexes, + pub ratio_pct98_usd: Indexes, + pub ratio_pct99: Indexes, + pub ratio_pct99_usd: Indexes, + pub ratio_sd: Ratio1ySdPattern, +} + +impl ActivePriceRatioPattern { + pub fn new(client: Arc, base_path: &str) -> Self { + Self { + ratio: Indexes::new(client.clone(), &format!("{base_path}/ratio")), + ratio_1m_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1m_sma")), + ratio_1w_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1w_sma")), + ratio_1y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_1y_sd")), + ratio_2y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_2y_sd")), + ratio_4y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_4y_sd")), + ratio_pct1: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct1")), + ratio_pct1_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct1_usd")), + ratio_pct2: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct2")), + ratio_pct2_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct2_usd")), + ratio_pct5: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct5")), + ratio_pct5_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct5_usd")), + ratio_pct95: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct95")), + ratio_pct95_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct95_usd")), + ratio_pct98: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct98")), + ratio_pct98_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct98_usd")), + ratio_pct99: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct99")), + ratio_pct99_usd: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct99_usd")), + ratio_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_sd")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct RelativePattern2 { pub neg_unrealized_loss_rel_to_market_cap: Indexes27, @@ -1014,43 +1063,6 @@ impl RelativePattern2 { } } -/// Pattern struct for repeated tree structure. -pub struct ActivePriceRatioPattern { - pub ratio: Indexes, - pub ratio_1m_sma: Indexes, - pub ratio_1w_sma: Indexes, - pub ratio_1y_sd: Ratio1ySdPattern, - pub ratio_2y_sd: Ratio1ySdPattern, - pub ratio_4y_sd: Ratio1ySdPattern, - pub ratio_pct1: Indexes, - pub ratio_pct2: Indexes, - pub ratio_pct5: Indexes, - pub ratio_pct95: Indexes, - pub ratio_pct98: Indexes, - pub ratio_pct99: Indexes, - pub ratio_sd: Ratio1ySdPattern, -} - -impl ActivePriceRatioPattern { - pub fn new(client: Arc, base_path: &str) -> Self { - Self { - ratio: Indexes::new(client.clone(), &format!("{base_path}/ratio")), - ratio_1m_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1m_sma")), - ratio_1w_sma: Indexes::new(client.clone(), &format!("{base_path}/ratio_1w_sma")), - ratio_1y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_1y_sd")), - ratio_2y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_2y_sd")), - ratio_4y_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_4y_sd")), - ratio_pct1: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct1")), - ratio_pct2: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct2")), - ratio_pct5: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct5")), - ratio_pct95: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct95")), - ratio_pct98: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct98")), - ratio_pct99: Indexes::new(client.clone(), &format!("{base_path}/ratio_pct99")), - ratio_sd: Ratio1ySdPattern::new(client.clone(), &format!("{base_path}/ratio_sd")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct AXbtPattern { pub _1d_dominance: BlockCountPattern, @@ -1123,31 +1135,31 @@ impl BitcoinPattern { /// Pattern struct for repeated tree structure. pub struct BlockSizePattern { - pub average: Indexes4, + pub average: Indexes3, pub cumulative: Indexes3, - pub max: Indexes4, - pub median: Indexes5, - pub min: Indexes4, - pub pct10: Indexes5, - pub pct25: Indexes5, - pub pct75: Indexes5, - pub pct90: Indexes5, - pub sum: Indexes4, + pub max: Indexes3, + pub median: Indexes2, + pub min: Indexes3, + pub pct10: Indexes2, + pub pct25: Indexes2, + pub pct75: Indexes2, + pub pct90: Indexes2, + pub sum: Indexes3, } impl BlockSizePattern { pub fn new(client: Arc, base_path: &str) -> Self { Self { - average: Indexes4::new(client.clone(), &format!("{base_path}/average")), + average: Indexes3::new(client.clone(), &format!("{base_path}/average")), cumulative: Indexes3::new(client.clone(), &format!("{base_path}/cumulative")), - max: Indexes4::new(client.clone(), &format!("{base_path}/max")), - median: Indexes5::new(client.clone(), &format!("{base_path}/median")), - min: Indexes4::new(client.clone(), &format!("{base_path}/min")), - pct10: Indexes5::new(client.clone(), &format!("{base_path}/pct10")), - pct25: Indexes5::new(client.clone(), &format!("{base_path}/pct25")), - pct75: Indexes5::new(client.clone(), &format!("{base_path}/pct75")), - pct90: Indexes5::new(client.clone(), &format!("{base_path}/pct90")), - sum: Indexes4::new(client.clone(), &format!("{base_path}/sum")), + max: Indexes3::new(client.clone(), &format!("{base_path}/max")), + median: Indexes2::new(client.clone(), &format!("{base_path}/median")), + min: Indexes3::new(client.clone(), &format!("{base_path}/min")), + pct10: Indexes2::new(client.clone(), &format!("{base_path}/pct10")), + pct25: Indexes2::new(client.clone(), &format!("{base_path}/pct25")), + pct75: Indexes2::new(client.clone(), &format!("{base_path}/pct75")), + pct90: Indexes2::new(client.clone(), &format!("{base_path}/pct90")), + sum: Indexes3::new(client.clone(), &format!("{base_path}/sum")), } } } @@ -1319,21 +1331,21 @@ impl _0satsPattern { } /// Pattern struct for repeated tree structure. -pub struct UpTo1dPattern { +pub struct _10yTo12yPattern { pub activity: ActivityPattern, pub price_paid: PricePaidPattern2, - pub realized: RealizedPattern3, + pub realized: RealizedPattern2, pub relative: RelativePattern2, pub supply: SupplyPattern2, pub unrealized: UnrealizedPattern, } -impl UpTo1dPattern { +impl _10yTo12yPattern { pub fn new(client: Arc, base_path: &str) -> Self { Self { activity: ActivityPattern::new(client.clone(), &format!("{base_path}/activity")), price_paid: PricePaidPattern2::new(client.clone(), &format!("{base_path}/price_paid")), - realized: RealizedPattern3::new(client.clone(), &format!("{base_path}/realized")), + realized: RealizedPattern2::new(client.clone(), &format!("{base_path}/realized")), relative: RelativePattern2::new(client.clone(), &format!("{base_path}/relative")), supply: SupplyPattern2::new(client.clone(), &format!("{base_path}/supply")), unrealized: UnrealizedPattern::new(client.clone(), &format!("{base_path}/unrealized")), @@ -1365,21 +1377,21 @@ impl _0satsPattern2 { } /// Pattern struct for repeated tree structure. -pub struct _10yTo12yPattern { +pub struct UpTo1dPattern { pub activity: ActivityPattern, pub price_paid: PricePaidPattern2, - pub realized: RealizedPattern2, + pub realized: RealizedPattern3, pub relative: RelativePattern2, pub supply: SupplyPattern2, pub unrealized: UnrealizedPattern, } -impl _10yTo12yPattern { +impl UpTo1dPattern { pub fn new(client: Arc, base_path: &str) -> Self { Self { activity: ActivityPattern::new(client.clone(), &format!("{base_path}/activity")), price_paid: PricePaidPattern2::new(client.clone(), &format!("{base_path}/price_paid")), - realized: RealizedPattern2::new(client.clone(), &format!("{base_path}/realized")), + realized: RealizedPattern3::new(client.clone(), &format!("{base_path}/realized")), relative: RelativePattern2::new(client.clone(), &format!("{base_path}/relative")), supply: SupplyPattern2::new(client.clone(), &format!("{base_path}/supply")), unrealized: UnrealizedPattern::new(client.clone(), &format!("{base_path}/unrealized")), @@ -1387,27 +1399,6 @@ impl _10yTo12yPattern { } } -/// Pattern struct for repeated tree structure. -pub struct ActivityPattern { - pub coinblocks_destroyed: BlockCountPattern, - pub coindays_destroyed: BlockCountPattern, - pub satblocks_destroyed: Indexes2, - pub satdays_destroyed: Indexes2, - pub sent: FeePattern2, -} - -impl ActivityPattern { - pub fn new(client: Arc, base_path: &str) -> Self { - Self { - coinblocks_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coinblocks_destroyed")), - coindays_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coindays_destroyed")), - satblocks_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satblocks_destroyed")), - satdays_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satdays_destroyed")), - sent: FeePattern2::new(client.clone(), &format!("{base_path}/sent")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct SupplyPattern2 { pub supply: SupplyPattern, @@ -1430,20 +1421,22 @@ impl SupplyPattern2 { } /// Pattern struct for repeated tree structure. -pub struct FeePattern2 { - pub base: Indexes2, - pub bitcoin: BlockCountPattern, - pub dollars: BlockCountPattern, - pub sats: SatsPattern, +pub struct ActivityPattern { + pub coinblocks_destroyed: BlockCountPattern, + pub coindays_destroyed: BlockCountPattern, + pub satblocks_destroyed: Indexes2, + pub satdays_destroyed: Indexes2, + pub sent: FeePattern2, } -impl FeePattern2 { +impl ActivityPattern { pub fn new(client: Arc, base_path: &str) -> Self { Self { - base: Indexes2::new(client.clone(), &format!("{base_path}/base")), - bitcoin: BlockCountPattern::new(client.clone(), &format!("{base_path}/bitcoin")), - dollars: BlockCountPattern::new(client.clone(), &format!("{base_path}/dollars")), - sats: SatsPattern::new(client.clone(), &format!("{base_path}/sats")), + coinblocks_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coinblocks_destroyed")), + coindays_destroyed: BlockCountPattern::new(client.clone(), &format!("{base_path}/coindays_destroyed")), + satblocks_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satblocks_destroyed")), + satdays_destroyed: Indexes2::new(client.clone(), &format!("{base_path}/satdays_destroyed")), + sent: FeePattern2::new(client.clone(), &format!("{base_path}/sent")), } } } @@ -1468,18 +1461,20 @@ impl SupplyPattern { } /// Pattern struct for repeated tree structure. -pub struct UnclaimedRewardsPattern { +pub struct FeePattern2 { + pub base: Indexes2, pub bitcoin: BlockCountPattern, pub dollars: BlockCountPattern, - pub sats: BlockCountPattern, + pub sats: SatsPattern, } -impl UnclaimedRewardsPattern { +impl FeePattern2 { pub fn new(client: Arc, base_path: &str) -> Self { Self { + base: Indexes2::new(client.clone(), &format!("{base_path}/base")), bitcoin: BlockCountPattern::new(client.clone(), &format!("{base_path}/bitcoin")), dollars: BlockCountPattern::new(client.clone(), &format!("{base_path}/dollars")), - sats: BlockCountPattern::new(client.clone(), &format!("{base_path}/sats")), + sats: SatsPattern::new(client.clone(), &format!("{base_path}/sats")), } } } @@ -1501,6 +1496,23 @@ impl ActiveSupplyPattern { } } +/// Pattern struct for repeated tree structure. +pub struct UnclaimedRewardsPattern { + pub bitcoin: BlockCountPattern, + pub dollars: BlockCountPattern, + pub sats: BlockCountPattern, +} + +impl UnclaimedRewardsPattern { + pub fn new(client: Arc, base_path: &str) -> Self { + Self { + bitcoin: BlockCountPattern::new(client.clone(), &format!("{base_path}/bitcoin")), + dollars: BlockCountPattern::new(client.clone(), &format!("{base_path}/dollars")), + sats: BlockCountPattern::new(client.clone(), &format!("{base_path}/sats")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct CoinbasePattern { pub bitcoin: BitcoinPattern, @@ -1552,6 +1564,36 @@ impl BlockCountPattern { } } +/// Pattern struct for repeated tree structure. +pub struct SatsPattern { + pub cumulative: Indexes3, + pub sum: Indexes4, +} + +impl SatsPattern { + pub fn new(client: Arc, base_path: &str) -> Self { + Self { + cumulative: Indexes3::new(client.clone(), &format!("{base_path}/cumulative")), + sum: Indexes4::new(client.clone(), &format!("{base_path}/sum")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct SupplyValuePattern { + pub bitcoin: Indexes2, + pub dollars: Indexes2, +} + +impl SupplyValuePattern { + pub fn new(client: Arc, base_path: &str) -> Self { + Self { + bitcoin: Indexes2::new(client.clone(), &format!("{base_path}/bitcoin")), + dollars: Indexes2::new(client.clone(), &format!("{base_path}/dollars")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _1dReturns1mSdPattern { pub sd: Indexes, @@ -1583,36 +1625,6 @@ impl PricePaidPattern { } } -/// Pattern struct for repeated tree structure. -pub struct SupplyValuePattern { - pub bitcoin: Indexes2, - pub dollars: Indexes2, -} - -impl SupplyValuePattern { - pub fn new(client: Arc, base_path: &str) -> Self { - Self { - bitcoin: Indexes2::new(client.clone(), &format!("{base_path}/bitcoin")), - dollars: Indexes2::new(client.clone(), &format!("{base_path}/dollars")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct SatsPattern { - pub cumulative: Indexes3, - pub sum: Indexes4, -} - -impl SatsPattern { - pub fn new(client: Arc, base_path: &str) -> Self { - Self { - cumulative: Indexes3::new(client.clone(), &format!("{base_path}/cumulative")), - sum: Indexes4::new(client.clone(), &format!("{base_path}/sum")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct BitcoinPattern2 { pub base: Indexes2, diff --git a/crates/brk_computer/src/cointime.rs b/crates/brk_computer/src/cointime.rs index c2f9e6851..a6c1cb4ea 100644 --- a/crates/brk_computer/src/cointime.rs +++ b/crates/brk_computer/src/cointime.rs @@ -3,7 +3,7 @@ use std::path::Path; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Bitcoin, CheckedSub, Dollars, StoredF32, StoredF64, Version}; -use vecdb::{Database, Exit, IterableCloneableVec, PAGE_SIZE, TypedVecIterator}; +use vecdb::{Database, Exit, PAGE_SIZE, TypedVecIterator}; use crate::{grouped::ComputedVecsFromDateIndex, utils::OptionExt}; @@ -107,7 +107,7 @@ impl Vecs { ComputedRatioVecsFromDateIndex::forced_import( &db, $name, - Source::Vec($source.dateindex.unwrap_last().boxed_clone()), + Some($source), v0, indexes, true, diff --git a/crates/brk_computer/src/grouped/lazy2_from_dateindex.rs b/crates/brk_computer/src/grouped/lazy2_from_dateindex.rs index 27ac9d5f3..715c9c46a 100644 --- a/crates/brk_computer/src/grouped/lazy2_from_dateindex.rs +++ b/crates/brk_computer/src/grouped/lazy2_from_dateindex.rs @@ -5,7 +5,7 @@ use brk_types::{ use schemars::JsonSchema; use vecdb::{AnyExportableVec, BinaryTransform, IterableCloneableVec, LazyVecFrom2}; -use super::{ComputedVecValue, ComputedVecsFromDateIndex, LazyTransform2Builder}; +use super::{ComputedVecValue, ComputedVecsFromDateIndex, ComputedVecsFromHeight, LazyTransform2Builder}; const VERSION: Version = Version::ZERO; @@ -87,6 +87,64 @@ where ), } } + + /// Create from a `ComputedVecsFromHeight` (first source) and `ComputedVecsFromDateIndex` (second source). + /// Used for computing USD values from price (Height-based) and ratio (DateIndex-based). + pub fn from_height_and_dateindex>( + name: &str, + version: Version, + source1: &ComputedVecsFromHeight, + source2: &ComputedVecsFromDateIndex, + ) -> Self { + let v = version + VERSION; + + Self { + dateindex: source2.dateindex.as_ref().map(|s2| { + LazyVecFrom2::transformed::( + name, + v, + source1.dateindex.unwrap_last().boxed_clone(), + s2.boxed_clone(), + ) + }), + weekindex: LazyTransform2Builder::from_lazy::( + name, + v, + &source1.weekindex, + &source2.weekindex, + ), + monthindex: LazyTransform2Builder::from_lazy::( + name, + v, + &source1.monthindex, + &source2.monthindex, + ), + quarterindex: LazyTransform2Builder::from_lazy::( + name, + v, + &source1.quarterindex, + &source2.quarterindex, + ), + semesterindex: LazyTransform2Builder::from_lazy::( + name, + v, + &source1.semesterindex, + &source2.semesterindex, + ), + yearindex: LazyTransform2Builder::from_lazy::( + name, + v, + &source1.yearindex, + &source2.yearindex, + ), + decadeindex: LazyTransform2Builder::from_lazy::( + name, + v, + &source1.decadeindex, + &source2.decadeindex, + ), + } + } } impl Traversable for LazyVecsFrom2FromDateIndex diff --git a/crates/brk_computer/src/grouped/ratio_from_dateindex.rs b/crates/brk_computer/src/grouped/ratio_from_dateindex.rs index 36d571e3e..aa93fc086 100644 --- a/crates/brk_computer/src/grouped/ratio_from_dateindex.rs +++ b/crates/brk_computer/src/grouped/ratio_from_dateindex.rs @@ -16,7 +16,7 @@ use crate::{ utils::{OptionExt, get_percentile}, }; -use super::{ComputedVecsFromDateIndex, VecBuilderOptions}; +use super::{ComputedVecsFromDateIndex, ComputedVecsFromHeight, VecBuilderOptions}; #[derive(Clone, Traversable)] pub struct ComputedRatioVecsFromDateIndex { @@ -51,7 +51,7 @@ impl ComputedRatioVecsFromDateIndex { pub fn forced_import( db: &Database, name: &str, - source: Source, + metric_price: Option<&ComputedVecsFromHeight>, version: Version, indexes: &indexes::Vecs, extended: bool, @@ -73,8 +73,9 @@ impl ComputedRatioVecsFromDateIndex { .unwrap() }; } - // Create sources first so lazy vecs can reference them - let price = source.is_compute().then(|| { + // Create price sources first so lazy vecs can reference them + // Only compute internally when metric_price is None + let price = metric_price.is_none().then(|| { ComputedVecsFromDateIndex::forced_import(db, name, Source::Compute, v, indexes, opts) .unwrap() }); @@ -103,16 +104,29 @@ impl ComputedRatioVecsFromDateIndex { let ratio_pct1 = extended.then(|| import!("ratio_pct1")); // Create lazy usd vecs from price and ratio sources + // Use from_height_and_dateindex when metric_price is provided (external price source) + // Use from_computed when price is computed internally macro_rules! lazy_usd { ($ratio:expr, $suffix:expr) => { - price.as_ref().zip($ratio.as_ref()).map(|(p, r)| { - LazyVecsFrom2FromDateIndex::from_computed::( - &format!("{name}_{}", $suffix), - v, - p, - r, - ) - }) + if let Some(mp) = metric_price { + $ratio.as_ref().map(|r| { + LazyVecsFrom2FromDateIndex::from_height_and_dateindex::( + &format!("{name}_{}", $suffix), + v, + mp, + r, + ) + }) + } else { + price.as_ref().zip($ratio.as_ref()).map(|(p, r)| { + LazyVecsFrom2FromDateIndex::from_computed::( + &format!("{name}_{}", $suffix), + v, + p, + r, + ) + }) + } }; } diff --git a/crates/brk_computer/src/market/import.rs b/crates/brk_computer/src/market/import.rs index db6f666ac..67cf30b48 100644 --- a/crates/brk_computer/src/market/import.rs +++ b/crates/brk_computer/src/market/import.rs @@ -61,7 +61,7 @@ impl Vecs { ComputedRatioVecsFromDateIndex::forced_import( &db, $name, - Source::Compute, + None, version + v0, indexes, true, diff --git a/crates/brk_computer/src/stateful/compute/mod.rs b/crates/brk_computer/src/stateful/compute/mod.rs index 5c7f39a2c..a2bba0faa 100644 --- a/crates/brk_computer/src/stateful/compute/mod.rs +++ b/crates/brk_computer/src/stateful/compute/mod.rs @@ -14,7 +14,7 @@ pub use readers::{ pub use recover::{StartMode, determine_start_mode, recover_state, reset_state}; /// Flush checkpoint interval (every N blocks). -pub const FLUSH_INTERVAL: usize = 20_000; +pub const FLUSH_INTERVAL: usize = 10_000; // BIP30 duplicate coinbase heights (special case handling) pub const BIP30_DUPLICATE_HEIGHT_1: u32 = 91_842; diff --git a/crates/brk_computer/src/stateful/metrics/realized.rs b/crates/brk_computer/src/stateful/metrics/realized.rs index eb96fd297..914503111 100644 --- a/crates/brk_computer/src/stateful/metrics/realized.rs +++ b/crates/brk_computer/src/stateful/metrics/realized.rs @@ -249,12 +249,7 @@ impl RealizedMetrics { indexes_to_realized_price_extra: ComputedRatioVecsFromDateIndex::forced_import( cfg.db, &cfg.name("realized_price"), - Source::Vec( - indexes_to_realized_price - .dateindex - .unwrap_last() - .boxed_clone(), - ), + Some(&indexes_to_realized_price), cfg.version + v0, cfg.indexes, extended, diff --git a/crates/brk_computer/src/txins.rs b/crates/brk_computer/src/txins.rs index 7f0f3a796..de3627baf 100644 --- a/crates/brk_computer/src/txins.rs +++ b/crates/brk_computer/src/txins.rs @@ -12,7 +12,7 @@ use vecdb::{ use super::Indexes; -const BATCH_SIZE: usize = 3 * 1024 * 1024 * 1024 / size_of::(); +const BATCH_SIZE: usize = 2 * 1024 * 1024 * 1024 / size_of::(); pub const DB_NAME: &str = "txins"; #[derive(Clone, Traversable)] diff --git a/crates/brk_computer/src/txouts.rs b/crates/brk_computer/src/txouts.rs index 5f7becbf8..fed09e18d 100644 --- a/crates/brk_computer/src/txouts.rs +++ b/crates/brk_computer/src/txouts.rs @@ -13,6 +13,7 @@ use vecdb::{ use super::{Indexes, txins}; pub const DB_NAME: &str = "txouts"; +const HEIGHT_BATCH: u32 = 10_000; #[derive(Clone, Traversable)] pub struct Vecs { @@ -101,7 +102,6 @@ impl Vecs { starting_indexes.height ); - const HEIGHT_BATCH: u32 = 20_000; let mut pairs: Vec<(TxOutIndex, TxInIndex)> = Vec::new(); let mut batch_start_height = min_height;