diff --git a/Cargo.lock b/Cargo.lock index f7ce3629f..f88b91dcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3864,8 +3864,6 @@ checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" [[package]] name = "seqdb" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c7d8532f6feaa3a6b8ebd8d311e6adce7d71bc82ee037ec87dc271a66b112b" dependencies = [ "libc", "log", @@ -4691,8 +4689,6 @@ checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23" [[package]] name = "vecdb" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2240e7d9599fe71411915ec56ce7f9e9aac3eb946cd12f5f0705d7422119a4" dependencies = [ "ctrlc", "log", @@ -4711,8 +4707,6 @@ dependencies = [ [[package]] name = "vecdb_derive" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef29d5571fcd184c6212019a7eb2808395f961686121e04e692d52bb8e007f33" dependencies = [ "quote", "syn 2.0.104", diff --git a/Cargo.toml b/Cargo.toml index ce1308035..398272080 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,8 +52,8 @@ serde_bytes = "0.11.17" serde_derive = "1.0.219" serde_json = { version = "1.0.142", features = ["float_roundtrip"] } tokio = { version = "1.47.1", features = ["rt-multi-thread"] } -# vecdb = { path = "../seqdb/crates/vecdb", features = ["derive"]} -vecdb = { version = "0.1.1", features = ["derive"]} +vecdb = { path = "../seqdb/crates/vecdb", features = ["derive"]} +# vecdb = { version = "0.1.1", features = ["derive"]} zerocopy = "0.8.26" zerocopy-derive = "0.8.26" diff --git a/crates/brk_computer/src/blocks.rs b/crates/brk_computer/src/blocks.rs index 9e6ae77f3..76126a72e 100644 --- a/crates/brk_computer/src/blocks.rs +++ b/crates/brk_computer/src/blocks.rs @@ -6,9 +6,7 @@ use brk_structs::{ CheckedSub, DifficultyEpoch, HalvingEpoch, Height, StoredU32, StoredU64, Timestamp, Version, Weight, }; -use vecdb::{ - AnyCollectableVec, Computation, Database, EagerVec, Exit, Format, PAGE_SIZE, VecIterator, -}; +use vecdb::{AnyCollectableVec, Database, EagerVec, Exit, Format, PAGE_SIZE, VecIterator}; use crate::grouped::Source; @@ -40,7 +38,6 @@ impl Vecs { pub fn forced_import( parent: &Path, version: Version, - computation: Computation, format: Format, indexes: &indexes::Vecs, ) -> Result { @@ -59,8 +56,6 @@ impl Vecs { "timestamp", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_first(), )?, @@ -69,8 +64,6 @@ impl Vecs { "block_interval", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_percentiles() @@ -82,8 +75,6 @@ impl Vecs { "block_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -92,8 +83,6 @@ impl Vecs { "block_weight", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -102,8 +91,6 @@ impl Vecs { "block_size", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -118,8 +105,6 @@ impl Vecs { "block_vbytes", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, diff --git a/crates/brk_computer/src/cointime.rs b/crates/brk_computer/src/cointime.rs index 4c191cba6..bd4da6c7e 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_indexer::Indexer; use brk_structs::{Bitcoin, CheckedSub, Dollars, StoredF64, Version}; -use vecdb::{AnyCollectableVec, Computation, Database, Exit, Format, PAGE_SIZE, VecIterator}; +use vecdb::{AnyCollectableVec, Database, Exit, PAGE_SIZE, VecIterator}; use super::{ Indexes, @@ -50,8 +50,6 @@ impl Vecs { pub fn forced_import( parent: &Path, version: Version, - computation: Computation, - format: Format, indexes: &indexes::Vecs, price: Option<&price::Vecs>, ) -> Result { @@ -66,8 +64,6 @@ impl Vecs { "coinblocks_created", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -76,8 +72,6 @@ impl Vecs { "coinblocks_stored", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -86,8 +80,6 @@ impl Vecs { "liveliness", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -96,8 +88,6 @@ impl Vecs { "vaultedness", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -106,8 +96,6 @@ impl Vecs { "activity_to_vaultedness_ratio", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -116,8 +104,6 @@ impl Vecs { "vaulted_supply", Source::Compute, version + VERSION + Version::ONE, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -127,8 +113,6 @@ impl Vecs { "active_supply", Source::Compute, version + VERSION + Version::ONE, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -138,8 +122,6 @@ impl Vecs { "thermo_cap", Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -148,8 +130,6 @@ impl Vecs { "investor_cap", Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -158,8 +138,6 @@ impl Vecs { "vaulted_cap", Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -168,8 +146,6 @@ impl Vecs { "active_cap", Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -178,8 +154,6 @@ impl Vecs { "vaulted_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -188,8 +162,6 @@ impl Vecs { "vaulted_price", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -198,8 +170,6 @@ impl Vecs { "active_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -208,8 +178,6 @@ impl Vecs { "active_price", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -218,8 +186,6 @@ impl Vecs { "true_market_mean", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -228,8 +194,6 @@ impl Vecs { "true_market_mean", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -238,8 +202,6 @@ impl Vecs { "cointime_value_destroyed", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -248,8 +210,6 @@ impl Vecs { "cointime_value_created", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -258,8 +218,6 @@ impl Vecs { "cointime_value_stored", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -268,8 +226,6 @@ impl Vecs { "cointime_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -278,8 +234,6 @@ impl Vecs { "cointime_cap", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -288,8 +242,6 @@ impl Vecs { "cointime_price", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, diff --git a/crates/brk_computer/src/constants.rs b/crates/brk_computer/src/constants.rs index bb358b264..cbf2653ba 100644 --- a/crates/brk_computer/src/constants.rs +++ b/crates/brk_computer/src/constants.rs @@ -3,7 +3,7 @@ use std::path::Path; use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{StoredU16, Version}; -use vecdb::{AnyCollectableVec, AnyVec, Computation, Database, Exit, Format}; +use vecdb::{AnyCollectableVec, AnyVec, Database, Exit}; use crate::grouped::Source; @@ -26,13 +26,7 @@ pub struct Vecs { } impl Vecs { - pub fn forced_import( - parent: &Path, - version: Version, - computation: Computation, - format: Format, - indexes: &indexes::Vecs, - ) -> Result { + pub fn forced_import(parent: &Path, version: Version, indexes: &indexes::Vecs) -> Result { let db = Database::open(&parent.join("constants"))?; Ok(Self { @@ -41,8 +35,6 @@ impl Vecs { "constant_0", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -51,8 +43,6 @@ impl Vecs { "constant_1", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -61,8 +51,6 @@ impl Vecs { "constant_50", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -71,8 +59,6 @@ impl Vecs { "constant_100", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, diff --git a/crates/brk_computer/src/grouped/builder_lazy.rs b/crates/brk_computer/src/grouped/builder_lazy.rs new file mode 100644 index 000000000..d167ca9e3 --- /dev/null +++ b/crates/brk_computer/src/grouped/builder_lazy.rs @@ -0,0 +1,395 @@ +use brk_structs::Version; +use vecdb::{ + AnyBoxedIterableVec, AnyCloneableIterableVec, AnyCollectableVec, FromCoarserIndex, + LazyVecFrom2, StoredIndex, +}; + +use crate::grouped::{EagerVecBuilder, VecBuilderOptions}; + +use super::ComputedType; + +#[allow(clippy::type_complexity)] +#[derive(Clone)] +pub struct LazyVecBuilder +where + I: StoredIndex, + T: ComputedType, + S2T: ComputedType, +{ + pub first: Option>>, + pub average: Option>>, + pub sum: Option>>, + pub max: Option>>, + pub min: Option>>, + pub last: Option>>, + pub cumulative: Option>>, +} + +const VERSION: Version = Version::ZERO; + +impl LazyVecBuilder +where + I: StoredIndex, + T: ComputedType + 'static, + S1I: StoredIndex + 'static + FromCoarserIndex, + S2T: ComputedType, +{ + #[allow(clippy::too_many_arguments)] + pub fn forced_import( + name: &str, + version: Version, + source: Option>, + source_extra: &EagerVecBuilder, + len_source: AnyBoxedIterableVec, + options: LazyVecBuilderOptions, + ) -> Self { + let only_one_active = options.is_only_one_active(); + + let suffix = |s: &str| format!("{name}_{s}"); + + let maybe_suffix = |s: &str| { + if only_one_active { + name.to_string() + } else { + suffix(s) + } + }; + + Self { + first: options.first.then(|| { + Box::new(LazyVecFrom2::init( + &maybe_suffix("first"), + version + VERSION + Version::ZERO, + source_extra + .first + .as_ref() + .map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()), + len_source.clone(), + |i: I, source, len_source| { + if i.unwrap_to_usize() >= len_source.len() { + return None; + } + source + .next_at(S1I::min_from(i)) + .map(|(_, cow)| cow.into_owned()) + }, + )) + }), + last: options.last.then(|| { + Box::new(LazyVecFrom2::init( + name, + version + VERSION + Version::ZERO, + source_extra.last.as_ref().map_or_else( + || { + source + .as_ref() + .unwrap_or_else(|| { + dbg!(name, I::to_string()); + panic!() + }) + .clone() + }, + |v| v.clone(), + ), + len_source.clone(), + |i: I, source, len_source| { + if i.unwrap_to_usize() >= len_source.len() { + return None; + } + source + .next_at(S1I::max_from(i, source.len())) + .map(|(_, cow)| cow.into_owned()) + }, + )) + }), + min: options.min.then(|| { + Box::new(LazyVecFrom2::init( + &maybe_suffix("min"), + version + VERSION + Version::ZERO, + source_extra + .min + .as_ref() + .map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()), + len_source.clone(), + |i: I, source, len_source| { + if i.unwrap_to_usize() >= len_source.len() { + return None; + } + S1I::inclusive_range_from(i, source.len()) + .flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned())) + .min() + }, + )) + }), + max: options.max.then(|| { + Box::new(LazyVecFrom2::init( + &maybe_suffix("max"), + version + VERSION + Version::ZERO, + source_extra + .max + .as_ref() + .map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()), + len_source.clone(), + |i: I, source, len_source| { + if i.unwrap_to_usize() >= len_source.len() { + return None; + } + S1I::inclusive_range_from(i, source.len()) + .flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned())) + .max() + }, + )) + }), + average: options.average.then(|| { + Box::new(LazyVecFrom2::init( + &maybe_suffix("average"), + version + VERSION + Version::ZERO, + source_extra + .average + .as_ref() + .map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()), + len_source.clone(), + |i: I, source, len_source| { + if i.unwrap_to_usize() >= len_source.len() { + return None; + } + let vec = S1I::inclusive_range_from(i, source.len()) + .flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned())) + .collect::>(); + if vec.is_empty() { + return None; + } + let mut sum = T::from(0); + let len = vec.len(); + vec.into_iter().for_each(|v| sum += v); + Some(sum / len) + }, + )) + }), + sum: options.sum.then(|| { + Box::new(LazyVecFrom2::init( + &(if !options.last && !options.average && !options.min && !options.max { + name.to_string() + } else { + maybe_suffix("sum") + }), + version + VERSION + Version::ZERO, + source_extra + .sum + .as_ref() + .map_or_else(|| source.as_ref().unwrap().clone(), |v| v.clone()), + len_source.clone(), + |i: I, source, len_source| { + if i.unwrap_to_usize() >= len_source.len() { + return None; + } + let vec = S1I::inclusive_range_from(i, source.len()) + .flat_map(|i| source.next_at(i).map(|(_, cow)| cow.into_owned())) + .collect::>(); + if vec.is_empty() { + return None; + } + let mut sum = T::from(0); + vec.into_iter().for_each(|v| sum += v); + Some(sum) + }, + )) + }), + cumulative: options.cumulative.then(|| { + Box::new(LazyVecFrom2::init( + &suffix("cumulative"), + version + VERSION + Version::ZERO, + source_extra.cumulative.as_ref().unwrap().boxed_clone(), + len_source.clone(), + |i: I, source, len_source| { + if i.unwrap_to_usize() >= len_source.len() { + return None; + } + source + .next_at(S1I::max_from(i, source.len())) + .map(|(_, cow)| cow.into_owned()) + }, + )) + }), + } + } + + pub fn starting_index(&self, max_from: I) -> I { + max_from.min(I::from( + self.vecs().into_iter().map(|v| v.len()).min().unwrap(), + )) + } + + pub fn unwrap_first(&self) -> &LazyVecFrom2 { + self.first.as_ref().unwrap() + } + #[allow(unused)] + pub fn unwrap_average(&self) -> &LazyVecFrom2 { + self.average.as_ref().unwrap() + } + pub fn unwrap_sum(&self) -> &LazyVecFrom2 { + self.sum.as_ref().unwrap() + } + pub fn unwrap_max(&self) -> &LazyVecFrom2 { + self.max.as_ref().unwrap() + } + pub fn unwrap_min(&self) -> &LazyVecFrom2 { + self.min.as_ref().unwrap() + } + pub fn unwrap_last(&self) -> &LazyVecFrom2 { + self.last.as_ref().unwrap() + } + #[allow(unused)] + pub fn unwrap_cumulative(&self) -> &LazyVecFrom2 { + self.cumulative.as_ref().unwrap() + } + + pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> { + let mut v: Vec<&dyn AnyCollectableVec> = vec![]; + + if let Some(first) = self.first.as_ref() { + v.push(first.as_ref()); + } + if let Some(last) = self.last.as_ref() { + v.push(last.as_ref()); + } + if let Some(min) = self.min.as_ref() { + v.push(min.as_ref()); + } + if let Some(max) = self.max.as_ref() { + v.push(max.as_ref()); + } + if let Some(average) = self.average.as_ref() { + v.push(average.as_ref()); + } + if let Some(sum) = self.sum.as_ref() { + v.push(sum.as_ref()); + } + if let Some(cumulative) = self.cumulative.as_ref() { + v.push(cumulative.as_ref()); + } + + v + } +} + +#[derive(Default, Clone, Copy)] +pub struct LazyVecBuilderOptions { + average: bool, + sum: bool, + max: bool, + min: bool, + first: bool, + last: bool, + cumulative: bool, +} + +impl From for LazyVecBuilderOptions { + fn from(value: VecBuilderOptions) -> Self { + Self { + average: value.average(), + sum: value.sum(), + max: value.max(), + min: value.min(), + first: value.first(), + last: value.last(), + cumulative: value.cumulative(), + } + } +} + +impl LazyVecBuilderOptions { + pub fn add_first(mut self) -> Self { + self.first = true; + self + } + + pub fn add_last(mut self) -> Self { + self.last = true; + self + } + + pub fn add_min(mut self) -> Self { + self.min = true; + self + } + + pub fn add_max(mut self) -> Self { + self.max = true; + self + } + + pub fn add_average(mut self) -> Self { + self.average = true; + self + } + + pub fn add_sum(mut self) -> Self { + self.sum = true; + self + } + + pub fn add_cumulative(mut self) -> Self { + self.cumulative = true; + self + } + + #[allow(unused)] + pub fn rm_min(mut self) -> Self { + self.min = false; + self + } + + #[allow(unused)] + pub fn rm_max(mut self) -> Self { + self.max = false; + self + } + + #[allow(unused)] + pub fn rm_average(mut self) -> Self { + self.average = false; + self + } + + #[allow(unused)] + pub fn rm_sum(mut self) -> Self { + self.sum = false; + self + } + + #[allow(unused)] + pub fn rm_cumulative(mut self) -> Self { + self.cumulative = false; + self + } + + pub fn add_minmax(mut self) -> Self { + self.min = true; + self.max = true; + self + } + + pub fn is_only_one_active(&self) -> bool { + [ + self.average, + self.sum, + self.max, + self.min, + self.first, + self.last, + self.cumulative, + ] + .iter() + .filter(|b| **b) + .count() + == 1 + } + + pub fn copy_self_extra(&self) -> Self { + Self { + cumulative: self.cumulative, + ..Self::default() + } + } +} diff --git a/crates/brk_computer/src/grouped/from_dateindex.rs b/crates/brk_computer/src/grouped/from_dateindex.rs index 4449a5c53..ee85b88bb 100644 --- a/crates/brk_computer/src/grouped/from_dateindex.rs +++ b/crates/brk_computer/src/grouped/from_dateindex.rs @@ -5,11 +5,10 @@ use brk_structs::{ DateIndex, DecadeIndex, MonthIndex, QuarterIndex, SemesterIndex, Version, WeekIndex, YearIndex, }; use vecdb::{ - AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Computation, Database, EagerVec, - Exit, Format, + AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Database, EagerVec, Exit, Format, }; -use crate::{Indexes, grouped::ComputedVecBuilder, indexes}; +use crate::{Indexes, grouped::LazyVecBuilder, indexes}; use super::{ComputedType, EagerVecBuilder, Source, VecBuilderOptions}; @@ -20,12 +19,12 @@ where { pub dateindex: Option>, pub dateindex_extra: EagerVecBuilder, - pub weekindex: ComputedVecBuilder, - pub monthindex: ComputedVecBuilder, - pub quarterindex: ComputedVecBuilder, - pub semesterindex: ComputedVecBuilder, - pub yearindex: ComputedVecBuilder, - pub decadeindex: ComputedVecBuilder, + pub weekindex: LazyVecBuilder, + pub monthindex: LazyVecBuilder, + pub quarterindex: LazyVecBuilder, + pub semesterindex: LazyVecBuilder, + pub yearindex: LazyVecBuilder, + pub decadeindex: LazyVecBuilder, } const VERSION: Version = Version::ZERO; @@ -40,11 +39,11 @@ where name: &str, source: Source, version: Version, - format: Format, - computation: Computation, indexes: &indexes::Vecs, options: VecBuilderOptions, ) -> Result { + let format = Format::Compressed; + let dateindex = source.is_compute().then(|| { EagerVec::forced_import(db, name, version + VERSION + Version::ZERO, format).unwrap() }); @@ -62,72 +61,54 @@ where let dateindex_source = source.vec().or(dateindex.as_ref().map(|v| v.boxed_clone())); Ok(Self { - weekindex: ComputedVecBuilder::forced_import( - db, + weekindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - computation, dateindex_source.clone(), &dateindex_extra, indexes.weekindex_to_weekindex.boxed_clone(), options.into(), - )?, - monthindex: ComputedVecBuilder::forced_import( - db, + ), + monthindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, dateindex_source.clone(), &dateindex_extra, indexes.monthindex_to_monthindex.boxed_clone(), options.into(), - )?, - quarterindex: ComputedVecBuilder::forced_import( - db, + ), + quarterindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, dateindex_source.clone(), &dateindex_extra, indexes.quarterindex_to_quarterindex.boxed_clone(), options.into(), - )?, - semesterindex: ComputedVecBuilder::forced_import( - db, + ), + semesterindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, dateindex_source.clone(), &dateindex_extra, indexes.semesterindex_to_semesterindex.boxed_clone(), options.into(), - )?, - yearindex: ComputedVecBuilder::forced_import( - db, + ), + yearindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, dateindex_source.clone(), &dateindex_extra, indexes.yearindex_to_yearindex.boxed_clone(), options.into(), - )?, - decadeindex: ComputedVecBuilder::forced_import( - db, + ), + decadeindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, dateindex_source.clone(), &dateindex_extra, indexes.decadeindex_to_decadeindex.boxed_clone(), options.into(), - )?, + ), dateindex, dateindex_extra, }) @@ -159,12 +140,11 @@ where )?; let dateindex: Option<&EagerVec> = None; - self.compute_rest(indexes, starting_indexes, exit, dateindex) + self.compute_rest(starting_indexes, exit, dateindex) } pub fn compute_rest( &mut self, - indexes: &indexes::Vecs, starting_indexes: &Indexes, exit: &Exit, dateindex: Option<&impl AnyIterableVec>, @@ -179,42 +159,6 @@ where .extend(starting_indexes.dateindex, dateindex, exit)?; } - self.weekindex.compute_if_necessary( - starting_indexes.weekindex, - &indexes.weekindex_to_dateindex_count, - exit, - )?; - - self.monthindex.compute_if_necessary( - starting_indexes.monthindex, - &indexes.monthindex_to_dateindex_count, - exit, - )?; - - self.quarterindex.compute_if_necessary( - starting_indexes.quarterindex, - &indexes.quarterindex_to_monthindex_count, - exit, - )?; - - self.semesterindex.compute_if_necessary( - starting_indexes.semesterindex, - &indexes.semesterindex_to_monthindex_count, - exit, - )?; - - self.yearindex.compute_if_necessary( - starting_indexes.yearindex, - &indexes.yearindex_to_monthindex_count, - exit, - )?; - - self.decadeindex.compute_if_necessary( - starting_indexes.decadeindex, - &indexes.decadeindex_to_yearindex_count, - exit, - )?; - Ok(()) } diff --git a/crates/brk_computer/src/grouped/from_height.rs b/crates/brk_computer/src/grouped/from_height.rs index c58054e82..033e4e5b4 100644 --- a/crates/brk_computer/src/grouped/from_height.rs +++ b/crates/brk_computer/src/grouped/from_height.rs @@ -6,13 +6,12 @@ use brk_structs::{ Version, WeekIndex, YearIndex, }; use vecdb::{ - AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Computation, Database, EagerVec, - Exit, Format, + AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Database, EagerVec, Exit, Format, }; use crate::{ Indexes, - grouped::{ComputedVecBuilder, Source}, + grouped::{LazyVecBuilder, Source}, indexes, }; @@ -26,14 +25,14 @@ where pub height: Option>, pub height_extra: EagerVecBuilder, pub dateindex: EagerVecBuilder, - pub weekindex: ComputedVecBuilder, + pub weekindex: LazyVecBuilder, pub difficultyepoch: EagerVecBuilder, - pub monthindex: ComputedVecBuilder, - pub quarterindex: ComputedVecBuilder, - pub semesterindex: ComputedVecBuilder, - pub yearindex: ComputedVecBuilder, + pub monthindex: LazyVecBuilder, + pub quarterindex: LazyVecBuilder, + pub semesterindex: LazyVecBuilder, + pub yearindex: LazyVecBuilder, // TODO: pub halvingepoch: StorableVecGeneator, - pub decadeindex: ComputedVecBuilder, + pub decadeindex: LazyVecBuilder, } const VERSION: Version = Version::ZERO; @@ -49,11 +48,11 @@ where name: &str, source: Source, version: Version, - format: Format, - computation: Computation, indexes: &indexes::Vecs, options: VecBuilderOptions, ) -> Result { + let format = Format::Compressed; + let height = source.is_compute().then(|| { EagerVec::forced_import(db, name, version + VERSION + Version::ZERO, format).unwrap() }); @@ -77,72 +76,54 @@ where let options = options.remove_percentiles(); Ok(Self { - weekindex: ComputedVecBuilder::forced_import( - db, + weekindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - computation, None, &dateindex, indexes.weekindex_to_weekindex.boxed_clone(), options.into(), - )?, - monthindex: ComputedVecBuilder::forced_import( - db, + ), + monthindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.monthindex_to_monthindex.boxed_clone(), options.into(), - )?, - quarterindex: ComputedVecBuilder::forced_import( - db, + ), + quarterindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.quarterindex_to_quarterindex.boxed_clone(), options.into(), - )?, - semesterindex: ComputedVecBuilder::forced_import( - db, + ), + semesterindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.semesterindex_to_semesterindex.boxed_clone(), options.into(), - )?, - yearindex: ComputedVecBuilder::forced_import( - db, + ), + yearindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.yearindex_to_yearindex.boxed_clone(), options.into(), - )?, - decadeindex: ComputedVecBuilder::forced_import( - db, + ), + decadeindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.decadeindex_to_decadeindex.boxed_clone(), options.into(), - )?, + ), // halvingepoch: StorableVecGeneator::forced_import(db, name, version + VERSION + Version::ZERO, format, options)?, height, height_extra, @@ -229,42 +210,6 @@ where )?; } - self.weekindex.compute_if_necessary( - starting_indexes.weekindex, - &indexes.weekindex_to_dateindex_count, - exit, - )?; - - self.monthindex.compute_if_necessary( - starting_indexes.monthindex, - &indexes.monthindex_to_dateindex_count, - exit, - )?; - - self.quarterindex.compute_if_necessary( - starting_indexes.quarterindex, - &indexes.quarterindex_to_monthindex_count, - exit, - )?; - - self.semesterindex.compute_if_necessary( - starting_indexes.semesterindex, - &indexes.semesterindex_to_monthindex_count, - exit, - )?; - - self.yearindex.compute_if_necessary( - starting_indexes.yearindex, - &indexes.yearindex_to_monthindex_count, - exit, - )?; - - self.decadeindex.compute_if_necessary( - starting_indexes.decadeindex, - &indexes.decadeindex_to_yearindex_count, - exit, - )?; - Ok(()) } diff --git a/crates/brk_computer/src/grouped/from_height_strict.rs b/crates/brk_computer/src/grouped/from_height_strict.rs index 206f64ed9..49671d629 100644 --- a/crates/brk_computer/src/grouped/from_height_strict.rs +++ b/crates/brk_computer/src/grouped/from_height_strict.rs @@ -30,9 +30,10 @@ where db: &Database, name: &str, version: Version, - format: Format, options: VecBuilderOptions, ) -> Result { + let format = Format::Compressed; + let height = EagerVec::forced_import(db, name, version + VERSION + Version::ZERO, format)?; let height_extra = EagerVecBuilder::forced_import( diff --git a/crates/brk_computer/src/grouped/from_txindex.rs b/crates/brk_computer/src/grouped/from_txindex.rs index c58f97a4c..835769efb 100644 --- a/crates/brk_computer/src/grouped/from_txindex.rs +++ b/crates/brk_computer/src/grouped/from_txindex.rs @@ -5,13 +5,13 @@ use brk_structs::{ Sats, SemesterIndex, TxIndex, Version, WeekIndex, YearIndex, }; use vecdb::{ - AnyCloneableIterableVec, AnyCollectableVec, AnyVec, CollectableVec, Computation, Database, - EagerVec, Exit, Format, GenericStoredVec, StoredIndex, VecIterator, + AnyCloneableIterableVec, AnyCollectableVec, AnyVec, CollectableVec, Database, EagerVec, Exit, + Format, GenericStoredVec, StoredIndex, VecIterator, }; use crate::{ Indexes, - grouped::{ComputedVecBuilder, Source}, + grouped::{LazyVecBuilder, Source}, indexes, price, }; @@ -25,14 +25,14 @@ where pub txindex: Option>>, pub height: EagerVecBuilder, pub dateindex: EagerVecBuilder, - pub weekindex: ComputedVecBuilder, + pub weekindex: LazyVecBuilder, pub difficultyepoch: EagerVecBuilder, - pub monthindex: ComputedVecBuilder, - pub quarterindex: ComputedVecBuilder, - pub semesterindex: ComputedVecBuilder, - pub yearindex: ComputedVecBuilder, + pub monthindex: LazyVecBuilder, + pub quarterindex: LazyVecBuilder, + pub semesterindex: LazyVecBuilder, + pub yearindex: LazyVecBuilder, // TODO: pub halvingepoch: StorableVecGeneator, - pub decadeindex: ComputedVecBuilder, + pub decadeindex: LazyVecBuilder, } const VERSION: Version = Version::ZERO; @@ -49,7 +49,6 @@ where source: Source, version: Version, format: Format, - computation: Computation, indexes: &indexes::Vecs, options: VecBuilderOptions, ) -> Result { @@ -79,72 +78,54 @@ where )?; Ok(Self { - weekindex: ComputedVecBuilder::forced_import( - db, + weekindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - computation, None, &dateindex, indexes.weekindex_to_weekindex.boxed_clone(), options.into(), - )?, - monthindex: ComputedVecBuilder::forced_import( - db, + ), + monthindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.monthindex_to_monthindex.boxed_clone(), options.into(), - )?, - quarterindex: ComputedVecBuilder::forced_import( - db, + ), + quarterindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.quarterindex_to_quarterindex.boxed_clone(), options.into(), - )?, - semesterindex: ComputedVecBuilder::forced_import( - db, + ), + semesterindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.semesterindex_to_semesterindex.boxed_clone(), options.into(), - )?, - yearindex: ComputedVecBuilder::forced_import( - db, + ), + yearindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.yearindex_to_yearindex.boxed_clone(), options.into(), - )?, - decadeindex: ComputedVecBuilder::forced_import( - db, + ), + decadeindex: LazyVecBuilder::forced_import( name, version + VERSION + Version::ZERO, - format, - Computation::Lazy, None, &dateindex, indexes.decadeindex_to_decadeindex.boxed_clone(), options.into(), - )?, + ), txindex, height, @@ -237,42 +218,6 @@ where exit, )?; - self.weekindex.compute_if_necessary( - starting_indexes.weekindex, - &indexes.weekindex_to_first_dateindex, - exit, - )?; - - self.monthindex.compute_if_necessary( - starting_indexes.monthindex, - &indexes.monthindex_to_dateindex_count, - exit, - )?; - - self.quarterindex.compute_if_necessary( - starting_indexes.quarterindex, - &indexes.quarterindex_to_monthindex_count, - exit, - )?; - - self.semesterindex.compute_if_necessary( - starting_indexes.semesterindex, - &indexes.semesterindex_to_monthindex_count, - exit, - )?; - - self.yearindex.compute_if_necessary( - starting_indexes.yearindex, - &indexes.yearindex_to_monthindex_count, - exit, - )?; - - self.decadeindex.compute_if_necessary( - starting_indexes.decadeindex, - &indexes.decadeindex_to_yearindex_count, - exit, - )?; - self.difficultyepoch.from_aligned( starting_indexes.difficultyepoch, &self.height, diff --git a/crates/brk_computer/src/grouped/mod.rs b/crates/brk_computer/src/grouped/mod.rs index 3970c3246..5dd681a5f 100644 --- a/crates/brk_computer/src/grouped/mod.rs +++ b/crates/brk_computer/src/grouped/mod.rs @@ -1,5 +1,5 @@ -mod builder_computed; mod builder_eager; +mod builder_lazy; mod computed; mod from_dateindex; mod from_height; @@ -12,8 +12,8 @@ mod value_from_height; mod value_from_txindex; mod value_height; -pub use builder_computed::*; pub use builder_eager::*; +pub use builder_lazy::*; use computed::*; pub use from_dateindex::*; pub use from_height::*; diff --git a/crates/brk_computer/src/grouped/ratio_from_dateindex.rs b/crates/brk_computer/src/grouped/ratio_from_dateindex.rs index ecbf3db20..e8a76e203 100644 --- a/crates/brk_computer/src/grouped/ratio_from_dateindex.rs +++ b/crates/brk_computer/src/grouped/ratio_from_dateindex.rs @@ -2,8 +2,8 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{Date, DateIndex, Dollars, StoredF32, Version}; use vecdb::{ - AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, CollectableVec, Computation, Database, - EagerVec, Exit, Format, GenericStoredVec, StoredIndex, VecIterator, + AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, CollectableVec, Database, EagerVec, + Exit, GenericStoredVec, StoredIndex, VecIterator, }; use crate::{Indexes, grouped::source::Source, indexes, price, utils::get_percentile}; @@ -62,8 +62,6 @@ impl ComputedRatioVecsFromDateIndex { name: &str, source: Source, version: Version, - format: Format, - computation: Computation, indexes: &indexes::Vecs, extended: bool, ) -> Result { @@ -76,8 +74,6 @@ impl ComputedRatioVecsFromDateIndex { name, Source::Compute, version + VERSION, - format, - computation, indexes, options, ) @@ -88,8 +84,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, )?, @@ -99,8 +93,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_sma"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -112,8 +104,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_1w_sma"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -125,8 +115,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_1m_sma"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -138,8 +126,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_1y_sma"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -151,8 +137,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_4y_sma"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -164,8 +148,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_1y_sma_momentum_oscillator"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -177,8 +159,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -190,8 +170,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_4y_sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -203,8 +181,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_1y_sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -216,8 +192,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p99_9"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -229,8 +203,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p99_5"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -242,8 +214,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p99"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -255,8 +225,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p1"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -268,8 +236,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p0_5"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -281,8 +247,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p0_1"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -294,8 +258,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p1sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -307,8 +269,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p2sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -320,8 +280,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p3sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -333,8 +291,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_m1sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -346,8 +302,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_m2sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -359,8 +313,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_m3sd"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -372,8 +324,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p99_9_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -385,8 +335,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p99_5_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -398,8 +346,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p99_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -411,8 +357,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p1_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -424,8 +368,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p0_5_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -437,8 +379,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p0_1_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -450,8 +390,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p1sd_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -463,8 +401,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p2sd_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -476,8 +412,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_p3sd_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -489,8 +423,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_m1sd_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -502,8 +434,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_m2sd_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -515,8 +445,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_m3sd_as_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -528,8 +456,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_zscore"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -541,8 +467,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_4y_zscore"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -554,8 +478,6 @@ impl ComputedRatioVecsFromDateIndex { &format!("{name}_ratio_1y_zscore"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, options, ) @@ -1084,91 +1006,76 @@ impl ComputedRatioVecsFromDateIndex { .try_for_each(|v| v.safe_flush(exit))?; self.ratio_p99_9.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p99_5.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p99.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p1.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p0_5.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p0_1.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_4y_sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_1y_sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p1sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p2sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_p3sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_m1sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_m2sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, )?; self.ratio_m3sd.as_mut().unwrap().compute_rest( - indexes, starting_indexes, exit, None as Option<&EagerVec<_, _>>, diff --git a/crates/brk_computer/src/grouped/value_from_dateindex.rs b/crates/brk_computer/src/grouped/value_from_dateindex.rs index ff3aa7ace..24307ba63 100644 --- a/crates/brk_computer/src/grouped/value_from_dateindex.rs +++ b/crates/brk_computer/src/grouped/value_from_dateindex.rs @@ -1,9 +1,7 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{Bitcoin, DateIndex, Dollars, Sats, Version}; -use vecdb::{ - AnyCollectableVec, CollectableVec, Computation, Database, EagerVec, Exit, Format, StoredVec, -}; +use vecdb::{AnyCollectableVec, CollectableVec, Database, EagerVec, Exit, StoredVec}; use crate::{ Indexes, @@ -30,8 +28,6 @@ impl ComputedValueVecsFromDateIndex { name: &str, source: Source, version: Version, - format: Format, - computation: Computation, options: VecBuilderOptions, compute_dollars: bool, indexes: &indexes::Vecs, @@ -42,8 +38,6 @@ impl ComputedValueVecsFromDateIndex { name, source, version + VERSION, - format, - computation, indexes, options, )?, @@ -52,8 +46,6 @@ impl ComputedValueVecsFromDateIndex { &format!("{name}_in_btc"), Source::Compute, version + VERSION, - format, - computation, indexes, options, )?, @@ -63,8 +55,6 @@ impl ComputedValueVecsFromDateIndex { &format!("{name}_in_usd"), Source::Compute, version + VERSION, - format, - computation, indexes, options, ) @@ -116,7 +106,7 @@ impl ComputedValueVecsFromDateIndex { ) -> Result<()> { if let Some(dateindex) = dateindex { self.sats - .compute_rest(indexes, starting_indexes, exit, Some(dateindex))?; + .compute_rest(starting_indexes, exit, Some(dateindex))?; self.bitcoin.compute_all( indexer, @@ -130,8 +120,7 @@ impl ComputedValueVecsFromDateIndex { } else { let dateindex: Option<&StoredVec> = None; - self.sats - .compute_rest(indexes, starting_indexes, exit, dateindex)?; + self.sats.compute_rest(starting_indexes, exit, dateindex)?; self.bitcoin.compute_all( indexer, diff --git a/crates/brk_computer/src/grouped/value_from_height.rs b/crates/brk_computer/src/grouped/value_from_height.rs index ced39a6bb..63c2135b2 100644 --- a/crates/brk_computer/src/grouped/value_from_height.rs +++ b/crates/brk_computer/src/grouped/value_from_height.rs @@ -1,9 +1,7 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{Bitcoin, Dollars, Height, Sats, Version}; -use vecdb::{ - AnyCollectableVec, CollectableVec, Computation, Database, EagerVec, Exit, Format, StoredVec, -}; +use vecdb::{AnyCollectableVec, CollectableVec, Database, EagerVec, Exit, StoredVec}; use crate::{ Indexes, @@ -30,8 +28,6 @@ impl ComputedValueVecsFromHeight { name: &str, source: Source, version: Version, - format: Format, - computation: Computation, options: VecBuilderOptions, compute_dollars: bool, indexes: &indexes::Vecs, @@ -42,8 +38,6 @@ impl ComputedValueVecsFromHeight { name, source, version + VERSION, - format, - computation, indexes, options, )?, @@ -52,8 +46,6 @@ impl ComputedValueVecsFromHeight { &format!("{name}_in_btc"), Source::Compute, version + VERSION, - format, - computation, indexes, options, )?, @@ -63,8 +55,6 @@ impl ComputedValueVecsFromHeight { &format!("{name}_in_usd"), Source::Compute, version + VERSION, - format, - computation, indexes, options, ) diff --git a/crates/brk_computer/src/grouped/value_from_txindex.rs b/crates/brk_computer/src/grouped/value_from_txindex.rs index 77196ce72..412a00eae 100644 --- a/crates/brk_computer/src/grouped/value_from_txindex.rs +++ b/crates/brk_computer/src/grouped/value_from_txindex.rs @@ -2,8 +2,8 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{Bitcoin, Close, Dollars, Height, Sats, TxIndex, Version}; use vecdb::{ - AnyCloneableIterableVec, AnyCollectableVec, CollectableVec, Computation, ComputedVecFrom3, - Database, Exit, Format, LazyVecFrom1, StoredIndex, StoredVec, + AnyCloneableIterableVec, AnyCollectableVec, CollectableVec, Database, Exit, Format, + LazyVecFrom1, LazyVecFrom3, StoredIndex, StoredVec, }; use crate::{Indexes, grouped::Source, indexes, price}; @@ -17,16 +17,7 @@ pub struct ComputedValueVecsFromTxindex { pub bitcoin: ComputedVecsFromTxindex, #[allow(clippy::type_complexity)] pub dollars_txindex: Option< - ComputedVecFrom3< - TxIndex, - Dollars, - TxIndex, - Bitcoin, - TxIndex, - Height, - Height, - Close, - >, + LazyVecFrom3>, >, pub dollars: Option>, } @@ -41,7 +32,6 @@ impl ComputedValueVecsFromTxindex { indexes: &indexes::Vecs, source: Source, version: Version, - computation: Computation, format: Format, price: Option<&price::Vecs>, options: VecBuilderOptions, @@ -57,7 +47,6 @@ impl ComputedValueVecsFromTxindex { source.clone(), version + VERSION, format, - computation, indexes, options, )?; @@ -82,18 +71,14 @@ impl ComputedValueVecsFromTxindex { Source::None, version + VERSION, format, - computation, indexes, options, )?; let dollars_txindex = price.map(|price| { - ComputedVecFrom3::forced_import_or_init_from_3( - computation, - db, + LazyVecFrom3::init( &name_in_usd, version + VERSION, - format, bitcoin_txindex.boxed_clone(), indexes.txindex_to_height.boxed_clone(), price.chainindexes_to_close.height.boxed_clone(), @@ -115,7 +100,6 @@ impl ComputedValueVecsFromTxindex { }) }, ) - .unwrap() }); Ok(Self { @@ -130,7 +114,6 @@ impl ComputedValueVecsFromTxindex { Source::None, version + VERSION, format, - computation, indexes, options, ) @@ -208,12 +191,6 @@ impl ComputedValueVecsFromTxindex { if let Some(dollars) = self.dollars.as_mut() { let dollars_txindex = self.dollars_txindex.as_mut().unwrap(); - dollars_txindex.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - dollars.compute_rest_from_bitcoin( indexer, indexes, diff --git a/crates/brk_computer/src/indexes.rs b/crates/brk_computer/src/indexes.rs index 39ac93a8b..aa1672134 100644 --- a/crates/brk_computer/src/indexes.rs +++ b/crates/brk_computer/src/indexes.rs @@ -11,8 +11,8 @@ use brk_structs::{ Timestamp, TxIndex, Txid, UnknownOutputIndex, Version, WeekIndex, YearIndex, }; use vecdb::{ - AnyCloneableIterableVec, AnyCollectableVec, Computation, ComputedVec, ComputedVecFrom1, - ComputedVecFrom2, Database, EagerVec, Exit, Format, PAGE_SIZE, StoredIndex, VecIterator, + AnyCloneableIterableVec, AnyCollectableVec, Database, EagerVec, Exit, Format, LazyVecFrom1, + LazyVecFrom2, PAGE_SIZE, StoredIndex, VecIterator, }; const VERSION: Version = Version::ZERO; @@ -34,7 +34,7 @@ pub struct Vecs { pub difficultyepoch_to_first_height: EagerVec, pub difficultyepoch_to_height_count: EagerVec, pub emptyoutputindex_to_emptyoutputindex: - ComputedVecFrom1, + LazyVecFrom1, pub halvingepoch_to_first_height: EagerVec, pub halvingepoch_to_halvingepoch: EagerVec, pub height_to_date: EagerVec, @@ -45,7 +45,7 @@ pub struct Vecs { pub height_to_height: EagerVec, pub height_to_timestamp_fixed: EagerVec, pub height_to_txindex_count: EagerVec, - pub inputindex_to_inputindex: ComputedVecFrom1, + pub inputindex_to_inputindex: LazyVecFrom1, pub monthindex_to_dateindex_count: EagerVec, pub monthindex_to_first_dateindex: EagerVec, pub monthindex_to_monthindex: EagerVec, @@ -53,27 +53,27 @@ pub struct Vecs { pub monthindex_to_semesterindex: EagerVec, pub monthindex_to_yearindex: EagerVec, pub opreturnindex_to_opreturnindex: - ComputedVecFrom1, - pub outputindex_to_outputindex: ComputedVecFrom1, + LazyVecFrom1, + pub outputindex_to_outputindex: LazyVecFrom1, pub outputindex_to_txindex: EagerVec, pub p2aaddressindex_to_p2aaddressindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2msoutputindex_to_p2msoutputindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2pk33addressindex_to_p2pk33addressindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2pk65addressindex_to_p2pk65addressindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2pkhaddressindex_to_p2pkhaddressindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2shaddressindex_to_p2shaddressindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2traddressindex_to_p2traddressindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2wpkhaddressindex_to_p2wpkhaddressindex: - ComputedVecFrom1, + LazyVecFrom1, pub p2wshaddressindex_to_p2wshaddressindex: - ComputedVecFrom1, + LazyVecFrom1, pub quarterindex_to_first_monthindex: EagerVec, pub quarterindex_to_monthindex_count: EagerVec, pub quarterindex_to_quarterindex: EagerVec, @@ -82,12 +82,12 @@ pub struct Vecs { pub semesterindex_to_semesterindex: EagerVec, pub txindex_to_height: EagerVec, pub txindex_to_input_count: - ComputedVecFrom2, + LazyVecFrom2, pub txindex_to_output_count: - ComputedVecFrom2, - pub txindex_to_txindex: ComputedVecFrom1, + LazyVecFrom2, + pub txindex_to_txindex: LazyVecFrom1, pub unknownoutputindex_to_unknownoutputindex: - ComputedVecFrom1, + LazyVecFrom1, pub weekindex_to_dateindex_count: EagerVec, pub weekindex_to_first_dateindex: EagerVec, pub weekindex_to_weekindex: EagerVec, @@ -98,52 +98,34 @@ pub struct Vecs { } impl Vecs { - pub fn forced_import( - parent: &Path, - version: Version, - indexer: &Indexer, - computation: Computation, - format: Format, - ) -> Result { + pub fn forced_import(parent: &Path, version: Version, indexer: &Indexer) -> Result { let db = Database::open(&parent.join("indexes"))?; db.set_min_len(PAGE_SIZE * 10_000_000)?; - let outputindex_to_outputindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + let outputindex_to_outputindex = LazyVecFrom1::init( "outputindex", version + VERSION + Version::ZERO, - format, indexer.vecs.outputindex_to_value.boxed_clone(), |index, _| Some(index), - )?; + ); - let inputindex_to_inputindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + let inputindex_to_inputindex = LazyVecFrom1::init( "inputindex", version + VERSION + Version::ZERO, - format, indexer.vecs.inputindex_to_outputindex.boxed_clone(), |index, _| Some(index), - )?; + ); - let txindex_to_txindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + let txindex_to_txindex = LazyVecFrom1::init( "txindex", version + VERSION + Version::ZERO, - format, indexer.vecs.txindex_to_txid.boxed_clone(), |index, _| Some(index), - )?; + ); - let txindex_to_input_count = ComputedVec::forced_import_or_init_from_2( - computation, - &db, + let txindex_to_input_count = LazyVecFrom2::init( "input_count", version + VERSION + Version::ZERO, - format, indexer.vecs.txindex_to_first_inputindex.boxed_clone(), indexer.vecs.inputindex_to_outputindex.boxed_clone(), |index: TxIndex, txindex_to_first_inputindex_iter, inputindex_to_outputindex_iter| { @@ -159,14 +141,11 @@ impl Vecs { StoredU64::from((start..end).count()) }) }, - )?; + ); - let txindex_to_output_count = ComputedVec::forced_import_or_init_from_2( - computation, - &db, + let txindex_to_output_count = LazyVecFrom2::init( "output_count", version + VERSION + Version::ZERO, - format, indexer.vecs.txindex_to_first_outputindex.boxed_clone(), indexer.vecs.outputindex_to_value.boxed_clone(), |index: TxIndex, txindex_to_first_outputindex_iter, outputindex_to_value_iter| { @@ -182,116 +161,80 @@ impl Vecs { StoredU64::from((start..end).count()) }) }, - )?; + ); - let p2pk33addressindex_to_p2pk33addressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + let p2pk33addressindex_to_p2pk33addressindex = LazyVecFrom1::init( "p2pk33addressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2pk33addressindex_to_p2pk33bytes.boxed_clone(), |index, _| Some(index), - )?; - let p2pk65addressindex_to_p2pk65addressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2pk65addressindex_to_p2pk65addressindex = LazyVecFrom1::init( "p2pk65addressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2pk65addressindex_to_p2pk65bytes.boxed_clone(), |index, _| Some(index), - )?; - let p2pkhaddressindex_to_p2pkhaddressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2pkhaddressindex_to_p2pkhaddressindex = LazyVecFrom1::init( "p2pkhaddressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2pkhaddressindex_to_p2pkhbytes.boxed_clone(), |index, _| Some(index), - )?; - let p2shaddressindex_to_p2shaddressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2shaddressindex_to_p2shaddressindex = LazyVecFrom1::init( "p2shaddressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2shaddressindex_to_p2shbytes.boxed_clone(), |index, _| Some(index), - )?; - let p2traddressindex_to_p2traddressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2traddressindex_to_p2traddressindex = LazyVecFrom1::init( "p2traddressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2traddressindex_to_p2trbytes.boxed_clone(), |index, _| Some(index), - )?; - let p2wpkhaddressindex_to_p2wpkhaddressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2wpkhaddressindex_to_p2wpkhaddressindex = LazyVecFrom1::init( "p2wpkhaddressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2wpkhaddressindex_to_p2wpkhbytes.boxed_clone(), |index, _| Some(index), - )?; - let p2wshaddressindex_to_p2wshaddressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2wshaddressindex_to_p2wshaddressindex = LazyVecFrom1::init( "p2wshaddressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2wshaddressindex_to_p2wshbytes.boxed_clone(), |index, _| Some(index), - )?; - let p2aaddressindex_to_p2aaddressindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2aaddressindex_to_p2aaddressindex = LazyVecFrom1::init( "p2aaddressindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2aaddressindex_to_p2abytes.boxed_clone(), |index, _| Some(index), - )?; - let p2msoutputindex_to_p2msoutputindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let p2msoutputindex_to_p2msoutputindex = LazyVecFrom1::init( "p2msoutputindex", version + VERSION + Version::ZERO, - format, indexer.vecs.p2msoutputindex_to_txindex.boxed_clone(), |index, _| Some(index), - )?; - let emptyoutputindex_to_emptyoutputindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let emptyoutputindex_to_emptyoutputindex = LazyVecFrom1::init( "emptyoutputindex", version + VERSION + Version::ZERO, - format, indexer.vecs.emptyoutputindex_to_txindex.boxed_clone(), |index, _| Some(index), - )?; - let unknownoutputindex_to_unknownoutputindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let unknownoutputindex_to_unknownoutputindex = LazyVecFrom1::init( "unknownoutputindex", version + VERSION + Version::ZERO, - format, indexer.vecs.unknownoutputindex_to_txindex.boxed_clone(), |index, _| Some(index), - )?; - let opreturnindex_to_opreturnindex = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + ); + let opreturnindex_to_opreturnindex = LazyVecFrom1::init( "opreturnindex", version + VERSION + Version::ZERO, - format, indexer.vecs.opreturnindex_to_txindex.boxed_clone(), |index, _| Some(index), - )?; + ); Ok(Self { emptyoutputindex_to_emptyoutputindex, @@ -316,259 +259,259 @@ impl Vecs { &db, "date", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, dateindex_to_dateindex: EagerVec::forced_import( &db, "dateindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, dateindex_to_first_height: EagerVec::forced_import( &db, "first_height", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, dateindex_to_monthindex: EagerVec::forced_import( &db, "monthindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, dateindex_to_weekindex: EagerVec::forced_import( &db, "weekindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, decadeindex_to_decadeindex: EagerVec::forced_import( &db, "decadeindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, decadeindex_to_first_yearindex: EagerVec::forced_import( &db, "first_yearindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, difficultyepoch_to_difficultyepoch: EagerVec::forced_import( &db, "difficultyepoch", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, difficultyepoch_to_first_height: EagerVec::forced_import( &db, "first_height", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, halvingepoch_to_first_height: EagerVec::forced_import( &db, "first_height", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, halvingepoch_to_halvingepoch: EagerVec::forced_import( &db, "halvingepoch", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_date: EagerVec::forced_import( &db, "date", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_difficultyepoch: EagerVec::forced_import( &db, "difficultyepoch", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_halvingepoch: EagerVec::forced_import( &db, "halvingepoch", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_height: EagerVec::forced_import( &db, "height", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, monthindex_to_first_dateindex: EagerVec::forced_import( &db, "first_dateindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, monthindex_to_monthindex: EagerVec::forced_import( &db, "monthindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, monthindex_to_quarterindex: EagerVec::forced_import( &db, "quarterindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, monthindex_to_semesterindex: EagerVec::forced_import( &db, "semesterindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, monthindex_to_yearindex: EagerVec::forced_import( &db, "yearindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, quarterindex_to_first_monthindex: EagerVec::forced_import( &db, "first_monthindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, semesterindex_to_first_monthindex: EagerVec::forced_import( &db, "first_monthindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, weekindex_to_first_dateindex: EagerVec::forced_import( &db, "first_dateindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, yearindex_to_first_monthindex: EagerVec::forced_import( &db, "first_monthindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, quarterindex_to_quarterindex: EagerVec::forced_import( &db, "quarterindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, semesterindex_to_semesterindex: EagerVec::forced_import( &db, "semesterindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, weekindex_to_weekindex: EagerVec::forced_import( &db, "weekindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, yearindex_to_decadeindex: EagerVec::forced_import( &db, "decadeindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, yearindex_to_yearindex: EagerVec::forced_import( &db, "yearindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_date_fixed: EagerVec::forced_import( &db, "date_fixed", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_dateindex: EagerVec::forced_import( &db, "dateindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, txindex_to_height: EagerVec::forced_import( &db, "height", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_timestamp_fixed: EagerVec::forced_import( &db, "timestamp_fixed", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, height_to_txindex_count: EagerVec::forced_import( &db, "txindex_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, dateindex_to_height_count: EagerVec::forced_import( &db, "height_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, weekindex_to_dateindex_count: EagerVec::forced_import( &db, "dateindex_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, difficultyepoch_to_height_count: EagerVec::forced_import( &db, "height_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, monthindex_to_dateindex_count: EagerVec::forced_import( &db, "dateindex_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, quarterindex_to_monthindex_count: EagerVec::forced_import( &db, "monthindex_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, semesterindex_to_monthindex_count: EagerVec::forced_import( &db, "monthindex_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, yearindex_to_monthindex_count: EagerVec::forced_import( &db, "monthindex_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, decadeindex_to_yearindex_count: EagerVec::forced_import( &db, "yearindex_count", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, outputindex_to_txindex: EagerVec::forced_import( &db, "txindex", version + VERSION + Version::ZERO, - format, + Format::Compressed, )?, db, @@ -596,24 +539,6 @@ impl Vecs { // OutputIndex // --- - self.outputindex_to_outputindex.compute_if_necessary( - starting_indexes.outputindex, - &indexer.vecs.outputindex_to_value, - exit, - )?; - - self.txindex_to_output_count.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - - self.txindex_to_input_count.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - self.outputindex_to_txindex.compute_inverse_less_to_more( starting_indexes.txindex, &indexer.vecs.txindex_to_first_outputindex, @@ -621,109 +546,10 @@ impl Vecs { exit, )?; - self.p2pk33addressindex_to_p2pk33addressindex - .compute_if_necessary( - starting_indexes.p2pk33addressindex, - &indexer.vecs.p2pk33addressindex_to_p2pk33bytes, - exit, - )?; - - self.p2pk65addressindex_to_p2pk65addressindex - .compute_if_necessary( - starting_indexes.p2pk65addressindex, - &indexer.vecs.p2pk65addressindex_to_p2pk65bytes, - exit, - )?; - - self.p2pkhaddressindex_to_p2pkhaddressindex - .compute_if_necessary( - starting_indexes.p2pkhaddressindex, - &indexer.vecs.p2pkhaddressindex_to_p2pkhbytes, - exit, - )?; - - self.p2shaddressindex_to_p2shaddressindex - .compute_if_necessary( - starting_indexes.p2shaddressindex, - &indexer.vecs.p2shaddressindex_to_p2shbytes, - exit, - )?; - - self.p2traddressindex_to_p2traddressindex - .compute_if_necessary( - starting_indexes.p2traddressindex, - &indexer.vecs.p2traddressindex_to_p2trbytes, - exit, - )?; - - self.p2wpkhaddressindex_to_p2wpkhaddressindex - .compute_if_necessary( - starting_indexes.p2wpkhaddressindex, - &indexer.vecs.p2wpkhaddressindex_to_p2wpkhbytes, - exit, - )?; - - self.p2wshaddressindex_to_p2wshaddressindex - .compute_if_necessary( - starting_indexes.p2wshaddressindex, - &indexer.vecs.p2wshaddressindex_to_p2wshbytes, - exit, - )?; - - self.emptyoutputindex_to_emptyoutputindex - .compute_if_necessary( - starting_indexes.emptyoutputindex, - &indexer.vecs.emptyoutputindex_to_txindex, - exit, - )?; - - self.p2msoutputindex_to_p2msoutputindex - .compute_if_necessary( - starting_indexes.p2msoutputindex, - &indexer.vecs.p2msoutputindex_to_txindex, - exit, - )?; - - self.opreturnindex_to_opreturnindex.compute_if_necessary( - starting_indexes.opreturnindex, - &indexer.vecs.opreturnindex_to_txindex, - exit, - )?; - - self.p2aaddressindex_to_p2aaddressindex - .compute_if_necessary( - starting_indexes.p2aaddressindex, - &indexer.vecs.p2aaddressindex_to_p2abytes, - exit, - )?; - - self.unknownoutputindex_to_unknownoutputindex - .compute_if_necessary( - starting_indexes.unknownoutputindex, - &indexer.vecs.unknownoutputindex_to_txindex, - exit, - )?; - - // --- - // InputIndex - // --- - - self.inputindex_to_inputindex.compute_if_necessary( - starting_indexes.inputindex, - &indexer.vecs.inputindex_to_outputindex, - exit, - )?; - // --- // TxIndex // --- - self.txindex_to_txindex.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - self.height_to_txindex_count.compute_count_from_indexes( starting_indexes.height, &indexer.vecs.height_to_first_txindex, diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index e25ec0fc1..528be4c49 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -7,7 +7,7 @@ use brk_fetcher::Fetcher; use brk_indexer::Indexer; use brk_structs::Version; use log::info; -use vecdb::{AnyCollectableVec, Computation, Exit, Format}; +use vecdb::{AnyCollectableVec, Exit, Format}; mod blocks; mod cointime; @@ -53,65 +53,42 @@ impl Computer { ) -> Result { let computed_path = outputs_path.join("computed"); - let computation = Computation::Lazy; - let format = Format::Compressed; - - let indexes = indexes::Vecs::forced_import( - &computed_path, - VERSION + Version::ZERO, - indexer, - computation, - format, - )?; + let indexes = + indexes::Vecs::forced_import(&computed_path, VERSION + Version::ZERO, indexer)?; let fetched = fetcher.map(|fetcher| { fetched::Vecs::forced_import(outputs_path, fetcher, VERSION + Version::ZERO).unwrap() }); + let format = Format::Compressed; + let price = fetched.is_some().then(|| { - price::Vecs::forced_import( - &computed_path, - VERSION + Version::ZERO, - computation, - format, - &indexes, - ) - .unwrap() + price::Vecs::forced_import(&computed_path, VERSION + Version::ZERO, format, &indexes) + .unwrap() }); Ok(Self { blocks: blocks::Vecs::forced_import( &computed_path, VERSION + Version::ZERO, - computation, - format, - &indexes, - )?, - mining: mining::Vecs::forced_import( - &computed_path, - VERSION + Version::ZERO, - computation, format, &indexes, )?, + mining: mining::Vecs::forced_import(&computed_path, VERSION + Version::ZERO, &indexes)?, constants: constants::Vecs::forced_import( &computed_path, VERSION + Version::ZERO, - computation, - format, &indexes, )?, market: market::Vecs::forced_import( &computed_path, VERSION + Version::ZERO, - computation, format, &indexes, )?, stateful: stateful::Vecs::forced_import( &computed_path, VERSION + Version::ZERO, - computation, format, &indexes, price.as_ref(), @@ -122,15 +99,12 @@ impl Computer { VERSION + Version::ZERO, indexer, &indexes, - computation, format, price.as_ref(), )?, cointime: cointime::Vecs::forced_import( &computed_path, VERSION + Version::ZERO, - computation, - format, &indexes, price.as_ref(), )?, diff --git a/crates/brk_computer/src/market.rs b/crates/brk_computer/src/market.rs index 6e41ef1b5..91e8725a7 100644 --- a/crates/brk_computer/src/market.rs +++ b/crates/brk_computer/src/market.rs @@ -4,8 +4,7 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{Date, DateIndex, Dollars, Height, Sats, StoredF32, StoredU16, Version}; use vecdb::{ - AnyCollectableVec, Computation, Database, EagerVec, Exit, Format, PAGE_SIZE, StoredIndex, - VecIterator, + AnyCollectableVec, Database, EagerVec, Exit, Format, PAGE_SIZE, StoredIndex, VecIterator, }; use crate::{ @@ -174,7 +173,6 @@ impl Vecs { pub fn forced_import( parent: &Path, version: Version, - computation: Computation, format: Format, indexes: &indexes::Vecs, ) -> Result { @@ -205,8 +203,6 @@ impl Vecs { "marketcap", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -215,8 +211,6 @@ impl Vecs { "ath", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -225,8 +219,6 @@ impl Vecs { "drawdown", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -235,8 +227,6 @@ impl Vecs { "days_since_ath", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -245,8 +235,6 @@ impl Vecs { "max_days_between_aths", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -255,8 +243,6 @@ impl Vecs { "max_years_between_aths", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -266,8 +252,6 @@ impl Vecs { "1w_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -276,8 +260,6 @@ impl Vecs { "8d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -286,8 +268,6 @@ impl Vecs { "13d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -296,8 +276,6 @@ impl Vecs { "21d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -306,8 +284,6 @@ impl Vecs { "1m_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -316,8 +292,6 @@ impl Vecs { "34d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -326,8 +300,6 @@ impl Vecs { "55d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -336,8 +308,6 @@ impl Vecs { "89d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -346,8 +316,6 @@ impl Vecs { "144d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -356,8 +324,6 @@ impl Vecs { "200d_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -366,8 +332,6 @@ impl Vecs { "1y_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -376,8 +340,6 @@ impl Vecs { "2y_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -386,8 +348,6 @@ impl Vecs { "200w_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -396,8 +356,6 @@ impl Vecs { "4y_sma", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, true, )?, @@ -407,8 +365,6 @@ impl Vecs { "1d_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -417,8 +373,6 @@ impl Vecs { "1w_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -427,8 +381,6 @@ impl Vecs { "1m_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -437,8 +389,6 @@ impl Vecs { "3m_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -447,8 +397,6 @@ impl Vecs { "6m_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -457,8 +405,6 @@ impl Vecs { "1y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -467,8 +413,6 @@ impl Vecs { "2y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -477,8 +421,6 @@ impl Vecs { "3y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -487,8 +429,6 @@ impl Vecs { "4y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -497,8 +437,6 @@ impl Vecs { "5y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -507,8 +445,6 @@ impl Vecs { "6y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -517,8 +453,6 @@ impl Vecs { "8y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -527,8 +461,6 @@ impl Vecs { "10y_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -537,8 +469,6 @@ impl Vecs { "2y_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -547,8 +477,6 @@ impl Vecs { "3y_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -557,8 +485,6 @@ impl Vecs { "4y_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -567,8 +493,6 @@ impl Vecs { "5y_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -577,8 +501,6 @@ impl Vecs { "6y_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -587,8 +509,6 @@ impl Vecs { "8y_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -597,8 +517,6 @@ impl Vecs { "10y_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -608,8 +526,6 @@ impl Vecs { "1w_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -618,8 +534,6 @@ impl Vecs { "1m_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -628,8 +542,6 @@ impl Vecs { "3m_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -638,8 +550,6 @@ impl Vecs { "6m_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -648,8 +558,6 @@ impl Vecs { "1y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -658,8 +566,6 @@ impl Vecs { "2y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -668,8 +574,6 @@ impl Vecs { "3y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -678,8 +582,6 @@ impl Vecs { "4y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -688,8 +590,6 @@ impl Vecs { "5y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -698,8 +598,6 @@ impl Vecs { "6y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -708,8 +606,6 @@ impl Vecs { "8y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -718,8 +614,6 @@ impl Vecs { "10y_dca_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -728,8 +622,6 @@ impl Vecs { "2y_dca_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -738,8 +630,6 @@ impl Vecs { "3y_dca_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -748,8 +638,6 @@ impl Vecs { "4y_dca_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -758,8 +646,6 @@ impl Vecs { "5y_dca_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -768,8 +654,6 @@ impl Vecs { "6y_dca_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -778,8 +662,6 @@ impl Vecs { "8y_dca_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -788,8 +670,6 @@ impl Vecs { "10y_dca_cagr", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -798,8 +678,6 @@ impl Vecs { "1w_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -808,8 +686,6 @@ impl Vecs { "1m_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -818,8 +694,6 @@ impl Vecs { "3m_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -828,8 +702,6 @@ impl Vecs { "6m_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -838,8 +710,6 @@ impl Vecs { "1y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -848,8 +718,6 @@ impl Vecs { "2y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -858,8 +726,6 @@ impl Vecs { "3y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -868,8 +734,6 @@ impl Vecs { "4y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -878,8 +742,6 @@ impl Vecs { "5y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -888,8 +750,6 @@ impl Vecs { "6y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -898,8 +758,6 @@ impl Vecs { "8y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -908,8 +766,6 @@ impl Vecs { "10y_dca_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -918,8 +774,6 @@ impl Vecs { "price_1d_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -928,8 +782,6 @@ impl Vecs { "price_1w_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -938,8 +790,6 @@ impl Vecs { "price_1m_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -948,8 +798,6 @@ impl Vecs { "price_3m_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -958,8 +806,6 @@ impl Vecs { "price_6m_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -968,8 +814,6 @@ impl Vecs { "price_1y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -978,8 +822,6 @@ impl Vecs { "price_2y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -988,8 +830,6 @@ impl Vecs { "price_3y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -998,8 +838,6 @@ impl Vecs { "price_4y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1008,8 +846,6 @@ impl Vecs { "price_5y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1018,8 +854,6 @@ impl Vecs { "price_6y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1028,8 +862,6 @@ impl Vecs { "price_8y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1038,8 +870,6 @@ impl Vecs { "price_10y_ago", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1048,8 +878,6 @@ impl Vecs { "1w_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1058,8 +886,6 @@ impl Vecs { "1m_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1068,8 +894,6 @@ impl Vecs { "3m_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1078,8 +902,6 @@ impl Vecs { "6m_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1088,8 +910,6 @@ impl Vecs { "1y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1098,8 +918,6 @@ impl Vecs { "2y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1108,8 +926,6 @@ impl Vecs { "3y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1118,8 +934,6 @@ impl Vecs { "4y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1128,8 +942,6 @@ impl Vecs { "5y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1138,8 +950,6 @@ impl Vecs { "6y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1148,8 +958,6 @@ impl Vecs { "8y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1158,8 +966,6 @@ impl Vecs { "10y_dca_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1169,8 +975,6 @@ impl Vecs { "dca_class_2025_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1179,8 +983,6 @@ impl Vecs { "dca_class_2024_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1189,8 +991,6 @@ impl Vecs { "dca_class_2023_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1199,8 +999,6 @@ impl Vecs { "dca_class_2022_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1209,8 +1007,6 @@ impl Vecs { "dca_class_2021_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1219,8 +1015,6 @@ impl Vecs { "dca_class_2020_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1229,8 +1023,6 @@ impl Vecs { "dca_class_2019_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1239,8 +1031,6 @@ impl Vecs { "dca_class_2018_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1249,8 +1039,6 @@ impl Vecs { "dca_class_2017_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1259,8 +1047,6 @@ impl Vecs { "dca_class_2016_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1269,8 +1055,6 @@ impl Vecs { "dca_class_2015_stack", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1280,8 +1064,6 @@ impl Vecs { "dca_class_2025_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1290,8 +1072,6 @@ impl Vecs { "dca_class_2024_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1300,8 +1080,6 @@ impl Vecs { "dca_class_2023_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1310,8 +1088,6 @@ impl Vecs { "dca_class_2022_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1320,8 +1096,6 @@ impl Vecs { "dca_class_2021_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1330,8 +1104,6 @@ impl Vecs { "dca_class_2020_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1340,8 +1112,6 @@ impl Vecs { "dca_class_2019_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1350,8 +1120,6 @@ impl Vecs { "dca_class_2018_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1360,8 +1128,6 @@ impl Vecs { "dca_class_2017_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1370,8 +1136,6 @@ impl Vecs { "dca_class_2016_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1380,8 +1144,6 @@ impl Vecs { "dca_class_2015_avg_price", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1391,8 +1153,6 @@ impl Vecs { "dca_class_2025_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1401,8 +1161,6 @@ impl Vecs { "dca_class_2024_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1411,8 +1169,6 @@ impl Vecs { "dca_class_2023_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1421,8 +1177,6 @@ impl Vecs { "dca_class_2022_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1431,8 +1185,6 @@ impl Vecs { "dca_class_2021_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1441,8 +1193,6 @@ impl Vecs { "dca_class_2020_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1451,8 +1201,6 @@ impl Vecs { "dca_class_2019_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1461,8 +1209,6 @@ impl Vecs { "dca_class_2018_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1471,8 +1217,6 @@ impl Vecs { "dca_class_2017_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1481,8 +1225,6 @@ impl Vecs { "dca_class_2016_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1491,8 +1233,6 @@ impl Vecs { "dca_class_2015_returns", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1502,8 +1242,6 @@ impl Vecs { "200d_sma_x2_4", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -1512,8 +1250,6 @@ impl Vecs { "200d_sma_x0_8", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, diff --git a/crates/brk_computer/src/mining.rs b/crates/brk_computer/src/mining.rs index 3a2647ff9..b02024af9 100644 --- a/crates/brk_computer/src/mining.rs +++ b/crates/brk_computer/src/mining.rs @@ -3,7 +3,7 @@ use std::path::Path; use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{DifficultyEpoch, HalvingEpoch, StoredF64, Version}; -use vecdb::{AnyCollectableVec, Computation, Database, Exit, Format, PAGE_SIZE, VecIterator}; +use vecdb::{AnyCollectableVec, Database, Exit, PAGE_SIZE, VecIterator}; use crate::grouped::Source; @@ -25,13 +25,7 @@ pub struct Vecs { } impl Vecs { - pub fn forced_import( - parent: &Path, - version: Version, - computation: Computation, - format: Format, - indexes: &indexes::Vecs, - ) -> Result { + pub fn forced_import(parent: &Path, version: Version, indexes: &indexes::Vecs) -> Result { let db = Database::open(&parent.join("mining"))?; db.set_min_len(PAGE_SIZE * 1_000_000)?; @@ -41,8 +35,6 @@ impl Vecs { "difficulty", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -51,8 +43,6 @@ impl Vecs { "difficultyepoch", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -61,8 +51,6 @@ impl Vecs { "halvingepoch", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, diff --git a/crates/brk_computer/src/price.rs b/crates/brk_computer/src/price.rs index 9ec6e6bb7..40e065b9e 100644 --- a/crates/brk_computer/src/price.rs +++ b/crates/brk_computer/src/price.rs @@ -7,8 +7,8 @@ use brk_structs::{ OHLCDollars, OHLCSats, Open, QuarterIndex, Sats, SemesterIndex, Version, WeekIndex, YearIndex, }; use vecdb::{ - AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Computation, Database, EagerVec, Exit, - Format, GenericStoredVec, PAGE_SIZE, RawVec, + AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, + GenericStoredVec, PAGE_SIZE, RawVec, }; use crate::{fetched, grouped::Source}; @@ -76,7 +76,6 @@ impl Vecs { pub fn forced_import( parent: &Path, version: Version, - computation: Computation, format: Format, indexes: &indexes::Vecs, ) -> Result { @@ -153,8 +152,6 @@ impl Vecs { "open", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_first(), )?, @@ -163,8 +160,6 @@ impl Vecs { "high", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_max(), )?, @@ -173,8 +168,6 @@ impl Vecs { "low", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_min(), )?, @@ -183,8 +176,6 @@ impl Vecs { "close", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -193,8 +184,6 @@ impl Vecs { "open_in_sats", Source::Compute, version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_first(), )?, @@ -203,8 +192,6 @@ impl Vecs { "high_in_sats", Source::Compute, version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_max(), )?, @@ -213,8 +200,6 @@ impl Vecs { "low_in_sats", Source::Compute, version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_min(), )?, @@ -223,8 +208,6 @@ impl Vecs { "close_in_sats", Source::Compute, version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -232,56 +215,48 @@ impl Vecs { &db, "open", version + VERSION + Version::ZERO, - format, VecBuilderOptions::default().add_first(), )?, chainindexes_to_high: ComputedVecsFromHeightStrict::forced_import( &db, "high", version + VERSION + Version::ZERO, - format, VecBuilderOptions::default().add_max(), )?, chainindexes_to_low: ComputedVecsFromHeightStrict::forced_import( &db, "low", version + VERSION + Version::ZERO, - format, VecBuilderOptions::default().add_min(), )?, chainindexes_to_close: ComputedVecsFromHeightStrict::forced_import( &db, "close", version + VERSION + Version::ZERO, - format, VecBuilderOptions::default().add_last(), )?, chainindexes_to_open_in_sats: ComputedVecsFromHeightStrict::forced_import( &db, "open_in_sats", version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, VecBuilderOptions::default().add_first(), )?, chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict::forced_import( &db, "high_in_sats", version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, VecBuilderOptions::default().add_max(), )?, chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict::forced_import( &db, "low_in_sats", version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, VecBuilderOptions::default().add_min(), )?, chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict::forced_import( &db, "close_in_sats", version + VERSION + VERSION_IN_SATS + Version::ZERO, - format, VecBuilderOptions::default().add_last(), )?, weekindex_to_ohlc: RawVec::forced_import( diff --git a/crates/brk_computer/src/stateful/address_cohort.rs b/crates/brk_computer/src/stateful/address_cohort.rs index 6f288e4f2..6496e851c 100644 --- a/crates/brk_computer/src/stateful/address_cohort.rs +++ b/crates/brk_computer/src/stateful/address_cohort.rs @@ -4,8 +4,8 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{Bitcoin, DateIndex, Dollars, Height, StoredU64, Version}; use vecdb::{ - AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Computation, Database, EagerVec, Exit, - Format, GenericStoredVec, VecIterator, + AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Database, EagerVec, Exit, Format, + GenericStoredVec, VecIterator, }; use crate::{ @@ -38,7 +38,6 @@ impl Vecs { pub fn forced_import( db: &Database, cohort_name: Option<&str>, - computation: Computation, format: Format, version: Version, indexes: &indexes::Vecs, @@ -70,15 +69,12 @@ impl Vecs { &suffix("address_count"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, inner: common::Vecs::forced_import( db, cohort_name, - computation, format, version, indexes, diff --git a/crates/brk_computer/src/stateful/address_cohorts.rs b/crates/brk_computer/src/stateful/address_cohorts.rs index bd0e9d220..9f6c8b646 100644 --- a/crates/brk_computer/src/stateful/address_cohorts.rs +++ b/crates/brk_computer/src/stateful/address_cohorts.rs @@ -7,7 +7,7 @@ use brk_structs::{ Dollars, GroupFilter, Height, Version, }; use derive_deref::{Deref, DerefMut}; -use vecdb::{AnyIterableVec, Computation, Database, Exit, Format}; +use vecdb::{AnyIterableVec, Database, Exit, Format}; use crate::{ Indexes, indexes, market, price, @@ -26,7 +26,6 @@ impl Vecs { pub fn forced_import( db: &Database, version: Version, - computation: Computation, format: Format, indexes: &indexes::Vecs, price: Option<&price::Vecs>, @@ -38,7 +37,6 @@ impl Vecs { _0sats: address_cohort::Vecs::forced_import( db, Some("addrs_with_0sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -49,7 +47,6 @@ impl Vecs { _1sat_to_10sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_1sat_under_10sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -60,7 +57,6 @@ impl Vecs { _10sats_to_100sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_10sats_under_100sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -71,7 +67,6 @@ impl Vecs { _100sats_to_1k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_100sats_under_1k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -82,7 +77,6 @@ impl Vecs { _1k_sats_to_10k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_1k_sats_under_10k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -93,7 +87,6 @@ impl Vecs { _10k_sats_to_100k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_10k_sats_under_100k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -104,7 +97,6 @@ impl Vecs { _100k_sats_to_1m_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_100k_sats_under_1m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -115,7 +107,6 @@ impl Vecs { _1m_sats_to_10m_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_1m_sats_under_10m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -126,7 +117,6 @@ impl Vecs { _10m_sats_to_1btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_10m_sats_under_1btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -137,7 +127,6 @@ impl Vecs { _1btc_to_10btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_1btc_under_10btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -148,7 +137,6 @@ impl Vecs { _10btc_to_100btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_10btc_under_100btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -159,7 +147,6 @@ impl Vecs { _100btc_to_1k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_100btc_under_1k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -170,7 +157,6 @@ impl Vecs { _1k_btc_to_10k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_1k_btc_under_10k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -181,7 +167,6 @@ impl Vecs { _10k_btc_to_100k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_10k_btc_under_100k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -192,7 +177,6 @@ impl Vecs { _100k_btc_or_more: address_cohort::Vecs::forced_import( db, Some("addrs_above_100k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -205,7 +189,6 @@ impl Vecs { _10sats: address_cohort::Vecs::forced_import( db, Some("addrs_under_10sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -216,7 +199,6 @@ impl Vecs { _100sats: address_cohort::Vecs::forced_import( db, Some("addrs_under_100sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -227,7 +209,6 @@ impl Vecs { _1k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_under_1k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -238,7 +219,6 @@ impl Vecs { _10k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_under_10k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -249,7 +229,6 @@ impl Vecs { _100k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_under_100k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -260,7 +239,6 @@ impl Vecs { _1m_sats: address_cohort::Vecs::forced_import( db, Some("addrs_under_1m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -271,7 +249,6 @@ impl Vecs { _10m_sats: address_cohort::Vecs::forced_import( db, Some("addrs_under_10m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -282,7 +259,6 @@ impl Vecs { _1btc: address_cohort::Vecs::forced_import( db, Some("addrs_under_1btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -293,7 +269,6 @@ impl Vecs { _10btc: address_cohort::Vecs::forced_import( db, Some("addrs_under_10btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -304,7 +279,6 @@ impl Vecs { _100btc: address_cohort::Vecs::forced_import( db, Some("addrs_under_100btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -315,7 +289,6 @@ impl Vecs { _1k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_under_1k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -326,7 +299,6 @@ impl Vecs { _10k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_under_10k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -337,7 +309,6 @@ impl Vecs { _100k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_under_100k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -350,7 +321,6 @@ impl Vecs { _1sat: address_cohort::Vecs::forced_import( db, Some("addrs_above_1sat"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -361,7 +331,6 @@ impl Vecs { _10sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_10sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -372,7 +341,6 @@ impl Vecs { _100sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_100sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -383,7 +351,6 @@ impl Vecs { _1k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_1k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -394,7 +361,6 @@ impl Vecs { _10k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_10k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -405,7 +371,6 @@ impl Vecs { _100k_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_100k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -416,7 +381,6 @@ impl Vecs { _1m_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_1m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -427,7 +391,6 @@ impl Vecs { _10m_sats: address_cohort::Vecs::forced_import( db, Some("addrs_above_10m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -438,7 +401,6 @@ impl Vecs { _1btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_1btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -449,7 +411,6 @@ impl Vecs { _10btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_10btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -460,7 +421,6 @@ impl Vecs { _100btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_100btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -471,7 +431,6 @@ impl Vecs { _1k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_1k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -482,7 +441,6 @@ impl Vecs { _10k_btc: address_cohort::Vecs::forced_import( db, Some("addrs_above_10k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, diff --git a/crates/brk_computer/src/stateful/common.rs b/crates/brk_computer/src/stateful/common.rs index d3fa30ad7..e76ff676e 100644 --- a/crates/brk_computer/src/stateful/common.rs +++ b/crates/brk_computer/src/stateful/common.rs @@ -4,8 +4,8 @@ use brk_structs::{ Bitcoin, DateIndex, Dollars, Height, Sats, StoredF32, StoredF64, StoredU64, Version, }; use vecdb::{ - AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Computation, - Database, EagerVec, Exit, Format, GenericStoredVec, VecIterator, + AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, AnyStoredVec, AnyVec, Database, + EagerVec, Exit, Format, GenericStoredVec, VecIterator, }; use crate::{ @@ -128,7 +128,6 @@ impl Vecs { pub fn forced_import( db: &Database, cohort_name: Option<&str>, - computation: Computation, format: Format, version: Version, indexes: &indexes::Vecs, @@ -209,8 +208,6 @@ impl Vecs { &suffix("supply_in_profit"), dateindex_to_supply_in_profit.as_ref().map(|v | v.boxed_clone()).into(), version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -233,8 +230,6 @@ impl Vecs { &suffix("supply_even"), dateindex_to_supply_even.as_ref().map(|v | v.boxed_clone()).into(), version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -257,8 +252,6 @@ impl Vecs { &suffix("supply_in_loss"), dateindex_to_supply_in_loss.as_ref().map(|v | v.boxed_clone()).into(), version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -281,8 +274,6 @@ impl Vecs { &suffix("unrealized_profit"), dateindex_to_unrealized_profit.as_ref().map(|v | v.boxed_clone()).into(), version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -322,8 +313,6 @@ impl Vecs { &suffix("unrealized_loss"), dateindex_to_unrealized_loss.as_ref().map(|v | v.boxed_clone()).into(), version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -345,8 +334,6 @@ impl Vecs { &suffix("realized_cap"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -358,8 +345,6 @@ impl Vecs { &suffix("min_price_paid"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -371,8 +356,6 @@ impl Vecs { &suffix("max_price_paid"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -397,8 +380,6 @@ impl Vecs { &suffix("supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -414,8 +395,6 @@ impl Vecs { &suffix("utxo_count"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -425,8 +404,6 @@ impl Vecs { &suffix("realized_price"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -438,8 +415,6 @@ impl Vecs { &suffix("realized_price"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, ratio_extended, ) @@ -460,8 +435,6 @@ impl Vecs { &suffix("realized_profit"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_sum() @@ -484,8 +457,6 @@ impl Vecs { &suffix("realized_loss"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_sum() @@ -499,8 +470,6 @@ impl Vecs { &suffix("negative_realized_loss"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), ) @@ -521,8 +490,6 @@ impl Vecs { &suffix("value_created"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -534,8 +501,6 @@ impl Vecs { &suffix("realized_value"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -556,8 +521,6 @@ impl Vecs { &suffix("adjusted_value_created"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -578,8 +541,6 @@ impl Vecs { &suffix("value_destroyed"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -600,8 +561,6 @@ impl Vecs { &suffix("adjusted_value_destroyed"), Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -613,8 +572,6 @@ impl Vecs { &suffix("realized_cap_30d_change"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -626,8 +583,6 @@ impl Vecs { &suffix("net_realized_profit_and_loss"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_sum() @@ -675,8 +630,6 @@ impl Vecs { &suffix("halved_supply"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -696,8 +649,6 @@ impl Vecs { &suffix("negative_unrealized_loss"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -718,8 +669,6 @@ impl Vecs { &suffix("net_unrealized_profit_and_loss"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -743,8 +692,6 @@ impl Vecs { &suffix("net_unrealized_profit_and_loss_relative_to_market_cap"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -757,8 +704,6 @@ impl Vecs { &suffix("realized_profit_relative_to_realized_cap"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -770,8 +715,6 @@ impl Vecs { &suffix("realized_loss_relative_to_realized_cap"), Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -784,8 +727,6 @@ impl Vecs { &suffix("net_realized_profit_and_loss_relative_to_realized_cap"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_sum(), ) @@ -858,8 +799,6 @@ impl Vecs { &suffix("supply_even_relative_to_own_supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -871,8 +810,6 @@ impl Vecs { &suffix("supply_in_loss_relative_to_own_supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -884,8 +821,6 @@ impl Vecs { &suffix("supply_in_profit_relative_to_own_supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -897,8 +832,6 @@ impl Vecs { &suffix("supply_relative_to_circulating_supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -945,8 +878,6 @@ impl Vecs { &suffix("supply_even_relative_to_circulating_supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -960,8 +891,6 @@ impl Vecs { &suffix("supply_in_loss_relative_to_circulating_supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -975,8 +904,6 @@ impl Vecs { &suffix("supply_in_profit_relative_to_circulating_supply"), Source::Compute, version + VERSION + Version::ONE, - format, - computation, indexes, VecBuilderOptions::default().add_last(), ) @@ -999,8 +926,6 @@ impl Vecs { &suffix("coinblocks_destroyed"), Source::Compute, version + VERSION + Version::TWO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -1009,8 +934,6 @@ impl Vecs { &suffix("coindays_destroyed"), Source::Compute, version + VERSION + Version::TWO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -1020,8 +943,6 @@ impl Vecs { &suffix("net_realized_profit_and_loss_cumulative_30d_change"), Source::Compute, version + VERSION + Version::new(3), - format, - computation, indexes, VecBuilderOptions::default().add_last() ) @@ -1033,8 +954,6 @@ impl Vecs { &suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap"), Source::Compute, version + VERSION + Version::new(3), - format, - computation, indexes, VecBuilderOptions::default().add_last() ) @@ -1046,8 +965,6 @@ impl Vecs { &suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap"), Source::Compute, version + VERSION + Version::new(3), - format, - computation, indexes, VecBuilderOptions::default().add_last() ) @@ -2310,7 +2227,6 @@ impl Vecs { .as_mut() .unwrap() .compute_rest( - indexes, starting_indexes, exit, Some(self.dateindex_to_unrealized_profit.as_ref().unwrap()), @@ -2319,7 +2235,6 @@ impl Vecs { .as_mut() .unwrap() .compute_rest( - indexes, starting_indexes, exit, Some(self.dateindex_to_unrealized_loss.as_ref().unwrap()), diff --git a/crates/brk_computer/src/stateful/mod.rs b/crates/brk_computer/src/stateful/mod.rs index 78c50e67f..c54ee0cc8 100644 --- a/crates/brk_computer/src/stateful/mod.rs +++ b/crates/brk_computer/src/stateful/mod.rs @@ -12,8 +12,8 @@ use brk_structs::{ use log::info; use rayon::prelude::*; use vecdb::{ - AnyCollectableVec, AnyStoredVec, AnyVec, CollectableVec, Computation, Database, EagerVec, Exit, - Format, GenericStoredVec, PAGE_SIZE, RawVec, Reader, Stamp, StoredIndex, VecIterator, + AnyCollectableVec, AnyStoredVec, AnyVec, CollectableVec, Database, EagerVec, Exit, Format, + GenericStoredVec, PAGE_SIZE, RawVec, Reader, Stamp, StoredIndex, VecIterator, }; use crate::{ @@ -85,7 +85,6 @@ impl Vecs { pub fn forced_import( parent: &Path, version: Version, - computation: Computation, format: Format, indexes: &indexes::Vecs, price: Option<&price::Vecs>, @@ -117,8 +116,6 @@ impl Vecs { "unspendable_supply", Source::None, version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -134,8 +131,6 @@ impl Vecs { "opreturn_supply", Source::None, version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default().add_last(), compute_dollars, indexes, @@ -145,8 +140,6 @@ impl Vecs { "address_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -155,8 +148,6 @@ impl Vecs { "empty_address_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -271,8 +262,6 @@ impl Vecs { "p2pk65_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -281,8 +270,6 @@ impl Vecs { "p2pk33_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -291,8 +278,6 @@ impl Vecs { "p2pkh_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -301,8 +286,6 @@ impl Vecs { "p2sh_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -311,8 +294,6 @@ impl Vecs { "p2wpkh_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -321,8 +302,6 @@ impl Vecs { "p2wsh_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -331,8 +310,6 @@ impl Vecs { "p2tr_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -341,8 +318,6 @@ impl Vecs { "p2a_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -355,8 +330,6 @@ impl Vecs { "p2pk65_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -365,8 +338,6 @@ impl Vecs { "p2pk33_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -375,8 +346,6 @@ impl Vecs { "p2pkh_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -385,8 +354,6 @@ impl Vecs { "p2sh_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -395,8 +362,6 @@ impl Vecs { "p2wpkh_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -405,8 +370,6 @@ impl Vecs { "p2wsh_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -415,8 +378,6 @@ impl Vecs { "p2tr_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -425,8 +386,6 @@ impl Vecs { "p2a_empty_address_count", Source::None, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -435,7 +394,6 @@ impl Vecs { utxo_cohorts: utxo_cohorts::Vecs::forced_import( &db, version, - computation, format, indexes, price, @@ -444,7 +402,6 @@ impl Vecs { address_cohorts: address_cohorts::Vecs::forced_import( &db, version, - computation, format, indexes, price, diff --git a/crates/brk_computer/src/stateful/utxo_cohort.rs b/crates/brk_computer/src/stateful/utxo_cohort.rs index ab7d4617d..643b17e8b 100644 --- a/crates/brk_computer/src/stateful/utxo_cohort.rs +++ b/crates/brk_computer/src/stateful/utxo_cohort.rs @@ -3,7 +3,7 @@ use std::{ops::Deref, path::Path}; use brk_error::Result; use brk_indexer::Indexer; use brk_structs::{Bitcoin, DateIndex, Dollars, Height, Version}; -use vecdb::{AnyCollectableVec, AnyIterableVec, Computation, Database, Exit, Format}; +use vecdb::{AnyCollectableVec, AnyIterableVec, Database, Exit, Format}; use crate::{ Indexes, UTXOCohortState, indexes, market, price, @@ -27,7 +27,6 @@ impl Vecs { pub fn forced_import( db: &Database, cohort_name: Option<&str>, - computation: Computation, format: Format, version: Version, indexes: &indexes::Vecs, @@ -53,7 +52,6 @@ impl Vecs { inner: common::Vecs::forced_import( db, cohort_name, - computation, format, version, indexes, diff --git a/crates/brk_computer/src/stateful/utxo_cohorts.rs b/crates/brk_computer/src/stateful/utxo_cohorts.rs index 4e004d429..71d54ae3d 100644 --- a/crates/brk_computer/src/stateful/utxo_cohorts.rs +++ b/crates/brk_computer/src/stateful/utxo_cohorts.rs @@ -8,7 +8,7 @@ use brk_structs::{ Height, Timestamp, UTXOGroups, Version, }; use derive_deref::{Deref, DerefMut}; -use vecdb::{AnyIterableVec, Computation, Database, Exit, Format, StoredIndex}; +use vecdb::{AnyIterableVec, Database, Exit, Format, StoredIndex}; use crate::{ Indexes, indexes, market, price, @@ -27,7 +27,6 @@ impl Vecs { pub fn forced_import( db: &Database, version: Version, - computation: Computation, format: Format, indexes: &indexes::Vecs, price: Option<&price::Vecs>, @@ -38,7 +37,6 @@ impl Vecs { all: utxo_cohort::Vecs::forced_import( db, None, - computation, format, version + VERSION + Version::ZERO, indexes, @@ -52,7 +50,6 @@ impl Vecs { short: utxo_cohort::Vecs::forced_import( db, Some("short_term_holders"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -65,7 +62,6 @@ impl Vecs { long: utxo_cohort::Vecs::forced_import( db, Some("long_term_holders"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -80,7 +76,6 @@ impl Vecs { _0: utxo_cohort::Vecs::forced_import( db, Some("epoch_0"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -93,7 +88,6 @@ impl Vecs { _1: utxo_cohort::Vecs::forced_import( db, Some("epoch_1"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -106,7 +100,6 @@ impl Vecs { _2: utxo_cohort::Vecs::forced_import( db, Some("epoch_2"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -119,7 +112,6 @@ impl Vecs { _3: utxo_cohort::Vecs::forced_import( db, Some("epoch_3"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -132,7 +124,6 @@ impl Vecs { _4: utxo_cohort::Vecs::forced_import( db, Some("epoch_4"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -147,7 +138,6 @@ impl Vecs { p2pk65: utxo_cohort::Vecs::forced_import( db, Some("p2pk65"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -160,7 +150,6 @@ impl Vecs { p2pk33: utxo_cohort::Vecs::forced_import( db, Some("p2pk33"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -173,7 +162,6 @@ impl Vecs { p2pkh: utxo_cohort::Vecs::forced_import( db, Some("p2pkh"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -186,7 +174,6 @@ impl Vecs { p2sh: utxo_cohort::Vecs::forced_import( db, Some("p2sh"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -199,7 +186,6 @@ impl Vecs { p2wpkh: utxo_cohort::Vecs::forced_import( db, Some("p2wpkh"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -212,7 +198,6 @@ impl Vecs { p2wsh: utxo_cohort::Vecs::forced_import( db, Some("p2wsh"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -225,7 +210,6 @@ impl Vecs { p2tr: utxo_cohort::Vecs::forced_import( db, Some("p2tr"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -238,7 +222,6 @@ impl Vecs { p2a: utxo_cohort::Vecs::forced_import( db, Some("p2a"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -251,7 +234,6 @@ impl Vecs { p2ms: utxo_cohort::Vecs::forced_import( db, Some("p2ms_outputs"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -264,7 +246,6 @@ impl Vecs { empty: utxo_cohort::Vecs::forced_import( db, Some("empty_outputs"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -277,7 +258,6 @@ impl Vecs { unknown: utxo_cohort::Vecs::forced_import( db, Some("unknown_outputs"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -292,7 +272,6 @@ impl Vecs { _1w: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_1w_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -305,7 +284,6 @@ impl Vecs { _1m: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_1m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -318,7 +296,6 @@ impl Vecs { _2m: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_2m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -331,7 +308,6 @@ impl Vecs { _3m: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_3m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -344,7 +320,6 @@ impl Vecs { _4m: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_4m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -357,7 +332,6 @@ impl Vecs { _5m: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_5m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -370,7 +344,6 @@ impl Vecs { _6m: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_6m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -383,7 +356,6 @@ impl Vecs { _1y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_1y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -396,7 +368,6 @@ impl Vecs { _2y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_2y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -409,7 +380,6 @@ impl Vecs { _3y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_3y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -422,7 +392,6 @@ impl Vecs { _4y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_4y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -435,7 +404,6 @@ impl Vecs { _5y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_5y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -448,7 +416,6 @@ impl Vecs { _6y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_6y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -461,7 +428,6 @@ impl Vecs { _7y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_7y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -474,7 +440,6 @@ impl Vecs { _8y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_8y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -487,7 +452,6 @@ impl Vecs { _10y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_10y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -500,7 +464,6 @@ impl Vecs { _12y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_12y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -513,7 +476,6 @@ impl Vecs { _15y: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_15y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -528,7 +490,6 @@ impl Vecs { _1d: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1d_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -541,7 +502,6 @@ impl Vecs { _1w: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1w_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -554,7 +514,6 @@ impl Vecs { _1m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -567,7 +526,6 @@ impl Vecs { _2m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_2m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -580,7 +538,6 @@ impl Vecs { _3m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_3m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -593,7 +550,6 @@ impl Vecs { _4m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_4m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -606,7 +562,6 @@ impl Vecs { _5m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_5m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -619,7 +574,6 @@ impl Vecs { _6m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_6m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -632,7 +586,6 @@ impl Vecs { _1y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -645,7 +598,6 @@ impl Vecs { _2y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_2y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -658,7 +610,6 @@ impl Vecs { _3y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_3y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -671,7 +622,6 @@ impl Vecs { _4y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_4y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -684,7 +634,6 @@ impl Vecs { _5y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_5y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -697,7 +646,6 @@ impl Vecs { _6y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_6y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -710,7 +658,6 @@ impl Vecs { _7y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_7y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -723,7 +670,6 @@ impl Vecs { _8y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_8y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -736,7 +682,6 @@ impl Vecs { _10y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_10y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -749,7 +694,6 @@ impl Vecs { _12y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_12y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -764,7 +708,6 @@ impl Vecs { up_to_1d: utxo_cohort::Vecs::forced_import( db, Some("utxos_up_to_1d_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -777,7 +720,6 @@ impl Vecs { _1d_to_1w: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1d_up_to_1w_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -790,7 +732,6 @@ impl Vecs { _1w_to_1m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1w_up_to_1m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -803,7 +744,6 @@ impl Vecs { _1m_to_2m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1m_up_to_2m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -816,7 +756,6 @@ impl Vecs { _2m_to_3m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_2m_up_to_3m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -829,7 +768,6 @@ impl Vecs { _3m_to_4m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_3m_up_to_4m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -842,7 +780,6 @@ impl Vecs { _4m_to_5m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_4m_up_to_5m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -855,7 +792,6 @@ impl Vecs { _5m_to_6m: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_5m_up_to_6m_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -868,7 +804,6 @@ impl Vecs { _6m_to_1y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_6m_up_to_1y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -881,7 +816,6 @@ impl Vecs { _1y_to_2y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_1y_up_to_2y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -894,7 +828,6 @@ impl Vecs { _2y_to_3y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_2y_up_to_3y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -907,7 +840,6 @@ impl Vecs { _3y_to_4y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_3y_up_to_4y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -920,7 +852,6 @@ impl Vecs { _4y_to_5y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_4y_up_to_5y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -933,7 +864,6 @@ impl Vecs { _5y_to_6y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_5y_up_to_6y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -946,7 +876,6 @@ impl Vecs { _6y_to_7y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_6y_up_to_7y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -959,7 +888,6 @@ impl Vecs { _7y_to_8y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_7y_up_to_8y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -972,7 +900,6 @@ impl Vecs { _8y_to_10y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_8y_up_to_10y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -985,7 +912,6 @@ impl Vecs { _10y_to_12y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_10y_up_to_12y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -998,7 +924,6 @@ impl Vecs { _12y_to_15y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_12y_up_to_15y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1011,7 +936,6 @@ impl Vecs { from_15y: utxo_cohort::Vecs::forced_import( db, Some("utxos_at_least_15y_old"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1026,7 +950,6 @@ impl Vecs { _0sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_with_0sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1039,7 +962,6 @@ impl Vecs { _1sat_to_10sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1sat_under_10sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1052,7 +974,6 @@ impl Vecs { _10sats_to_100sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10sats_under_100sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1065,7 +986,6 @@ impl Vecs { _100sats_to_1k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_100sats_under_1k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1078,7 +998,6 @@ impl Vecs { _1k_sats_to_10k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1k_sats_under_10k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1091,7 +1010,6 @@ impl Vecs { _10k_sats_to_100k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10k_sats_under_100k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1104,7 +1022,6 @@ impl Vecs { _100k_sats_to_1m_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_100k_sats_under_1m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1117,7 +1034,6 @@ impl Vecs { _1m_sats_to_10m_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1m_sats_under_10m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1130,7 +1046,6 @@ impl Vecs { _10m_sats_to_1btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10m_sats_under_1btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1143,7 +1058,6 @@ impl Vecs { _1btc_to_10btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1btc_under_10btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1156,7 +1070,6 @@ impl Vecs { _10btc_to_100btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10btc_under_100btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1169,7 +1082,6 @@ impl Vecs { _100btc_to_1k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_100btc_under_1k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1182,7 +1094,6 @@ impl Vecs { _1k_btc_to_10k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1k_btc_under_10k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1195,7 +1106,6 @@ impl Vecs { _10k_btc_to_100k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10k_btc_under_100k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1208,7 +1118,6 @@ impl Vecs { _100k_btc_or_more: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_100k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1223,7 +1132,6 @@ impl Vecs { _10sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_10sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1236,7 +1144,6 @@ impl Vecs { _100sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_100sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1249,7 +1156,6 @@ impl Vecs { _1k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_1k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1262,7 +1168,6 @@ impl Vecs { _10k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_10k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1275,7 +1180,6 @@ impl Vecs { _100k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_100k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1288,7 +1192,6 @@ impl Vecs { _1m_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_1m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1301,7 +1204,6 @@ impl Vecs { _10m_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_10m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1314,7 +1216,6 @@ impl Vecs { _1btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_1btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1327,7 +1228,6 @@ impl Vecs { _10btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_10btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1340,7 +1240,6 @@ impl Vecs { _100btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_100btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1353,7 +1252,6 @@ impl Vecs { _1k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_1k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1366,7 +1264,6 @@ impl Vecs { _10k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_10k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1379,7 +1276,6 @@ impl Vecs { _100k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_under_100k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1394,7 +1290,6 @@ impl Vecs { _1sat: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1sat"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1407,7 +1302,6 @@ impl Vecs { _10sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1420,7 +1314,6 @@ impl Vecs { _100sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_100sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1433,7 +1326,6 @@ impl Vecs { _1k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1446,7 +1338,6 @@ impl Vecs { _10k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1459,7 +1350,6 @@ impl Vecs { _100k_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_100k_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1472,7 +1362,6 @@ impl Vecs { _1m_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1485,7 +1374,6 @@ impl Vecs { _10m_sats: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10m_sats"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1498,7 +1386,6 @@ impl Vecs { _1btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1511,7 +1398,6 @@ impl Vecs { _10btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1524,7 +1410,6 @@ impl Vecs { _100btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_100btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1537,7 +1422,6 @@ impl Vecs { _1k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_1k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, @@ -1550,7 +1434,6 @@ impl Vecs { _10k_btc: utxo_cohort::Vecs::forced_import( db, Some("utxos_above_10k_btc"), - computation, format, version + VERSION + Version::ZERO, indexes, diff --git a/crates/brk_computer/src/transactions.rs b/crates/brk_computer/src/transactions.rs index 848beb567..53b035e07 100644 --- a/crates/brk_computer/src/transactions.rs +++ b/crates/brk_computer/src/transactions.rs @@ -7,9 +7,8 @@ use brk_structs::{ StoredU32, StoredU64, TxIndex, TxVersion, Version, Weight, }; use vecdb::{ - AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Computation, ComputedVec, - ComputedVecFrom1, ComputedVecFrom2, ComputedVecFrom3, Database, Exit, Format, PAGE_SIZE, - StoredIndex, VecIterator, + AnyCloneableIterableVec, AnyCollectableVec, AnyIterableVec, Database, EagerVec, Exit, Format, + LazyVecFrom1, LazyVecFrom2, LazyVecFrom3, PAGE_SIZE, StoredIndex, VecIterator, }; use crate::grouped::{ @@ -34,19 +33,11 @@ pub struct Vecs { pub indexes_to_feerate: ComputedVecsFromTxindex, /// Value == 0 when Coinbase pub txindex_to_input_value: - ComputedVecFrom3, + LazyVecFrom3, // pub indexes_to_input_value: ComputedVecsFromTxindex, pub indexes_to_opreturn_count: ComputedVecsFromHeight, - pub txindex_to_output_value: ComputedVecFrom3< - TxIndex, - Sats, - TxIndex, - OutputIndex, - TxIndex, - StoredU64, - OutputIndex, - Sats, - >, + pub txindex_to_output_value: + LazyVecFrom3, // pub indexes_to_output_value: ComputedVecsFromTxindex, pub indexes_to_p2a_count: ComputedVecsFromHeight, pub indexes_to_p2ms_count: ComputedVecsFromHeight, @@ -67,16 +58,14 @@ pub struct Vecs { pub indexes_to_tx_weight: ComputedVecsFromTxindex, pub indexes_to_unknownoutput_count: ComputedVecsFromHeight, pub inputindex_to_value: - ComputedVecFrom2, + LazyVecFrom2, pub indexes_to_input_count: ComputedVecsFromTxindex, - pub txindex_to_is_coinbase: - ComputedVecFrom2, + pub txindex_to_is_coinbase: LazyVecFrom2, pub indexes_to_output_count: ComputedVecsFromTxindex, - pub txindex_to_vsize: ComputedVecFrom1, - pub txindex_to_weight: - ComputedVecFrom2, - pub txindex_to_fee: ComputedVecFrom2, - pub txindex_to_feerate: ComputedVecFrom2, + pub txindex_to_vsize: LazyVecFrom1, + pub txindex_to_weight: LazyVecFrom2, + pub txindex_to_fee: EagerVec, + pub txindex_to_feerate: EagerVec, pub indexes_to_exact_utxo_count: ComputedVecsFromHeight, } @@ -86,7 +75,6 @@ impl Vecs { version: Version, indexer: &Indexer, indexes: &indexes::Vecs, - computation: Computation, format: Format, price: Option<&price::Vecs>, ) -> Result { @@ -95,12 +83,9 @@ impl Vecs { let compute_dollars = price.is_some(); - let inputindex_to_value = ComputedVec::forced_import_or_init_from_2( - computation, - &db, + let inputindex_to_value = LazyVecFrom2::init( "value", version + VERSION + Version::ZERO, - format, indexer.vecs.inputindex_to_outputindex.boxed_clone(), indexer.vecs.outputindex_to_value.boxed_clone(), |index: InputIndex, inputindex_to_outputindex_iter, outputindex_to_value_iter| { @@ -120,14 +105,11 @@ impl Vecs { } }) }, - )?; + ); - let txindex_to_weight = ComputedVec::forced_import_or_init_from_2( - computation, - &db, + let txindex_to_weight = LazyVecFrom2::init( "weight", version + VERSION + Version::ZERO, - format, indexer.vecs.txindex_to_base_size.boxed_clone(), indexer.vecs.txindex_to_total_size.boxed_clone(), |index: TxIndex, txindex_to_base_size_iter, txindex_to_total_size_iter| { @@ -148,14 +130,11 @@ impl Vecs { Weight::from(bitcoin::Weight::from_wu_usize(wu)) }) }, - )?; + ); - let txindex_to_vsize = ComputedVec::forced_import_or_init_from_1( - computation, - &db, + let txindex_to_vsize = LazyVecFrom1::init( "vsize", version + VERSION + Version::ZERO, - format, txindex_to_weight.boxed_clone(), |index: TxIndex, iter| { let index = index.unwrap_to_usize(); @@ -165,14 +144,11 @@ impl Vecs { ) }) }, - )?; + ); - let txindex_to_is_coinbase = ComputedVec::forced_import_or_init_from_2( - computation, - &db, + let txindex_to_is_coinbase = LazyVecFrom2::init( "is_coinbase", version + VERSION + Version::ZERO, - format, indexes.txindex_to_height.boxed_clone(), indexer.vecs.height_to_first_txindex.boxed_clone(), |index: TxIndex, txindex_to_height_iter, height_to_first_txindex_iter| { @@ -188,14 +164,11 @@ impl Vecs { StoredBool::from(index == txindex) }) }, - )?; + ); - let txindex_to_input_value = ComputedVec::forced_import_or_init_from_3( - computation, - &db, + let txindex_to_input_value = LazyVecFrom3::init( "input_value", version + VERSION + Version::ZERO, - format, indexer.vecs.txindex_to_first_inputindex.boxed_clone(), indexes.txindex_to_input_count.boxed_clone(), inputindex_to_value.boxed_clone(), @@ -224,7 +197,7 @@ impl Vecs { }) }) }, - )?; + ); // let indexes_to_input_value: ComputedVecsFromTxindex = // ComputedVecsFromTxindex::forced_import( @@ -240,12 +213,9 @@ impl Vecs { // .add_cumulative(), // )?; - let txindex_to_output_value = ComputedVec::forced_import_or_init_from_3( - computation, - &db, + let txindex_to_output_value = LazyVecFrom3::init( "output_value", version + VERSION + Version::ZERO, - format, indexer.vecs.txindex_to_first_outputindex.boxed_clone(), indexes.txindex_to_output_count.boxed_clone(), indexer.vecs.outputindex_to_value.boxed_clone(), @@ -274,7 +244,7 @@ impl Vecs { }) }) }, - )?; + ); // let indexes_to_output_value: ComputedVecsFromTxindex = // ComputedVecsFromTxindex::forced_import( @@ -290,47 +260,18 @@ impl Vecs { // .add_cumulative(), // )?; - let txindex_to_fee = ComputedVecFrom2::forced_import_or_init_from_2( - Computation::Eager, + let txindex_to_fee = EagerVec::forced_import( &db, "fee", version + VERSION + Version::ZERO, - format, - txindex_to_input_value.boxed_clone(), - txindex_to_output_value.boxed_clone(), - |txindex: TxIndex, input_iter, output_iter| { - let txindex = txindex.unwrap_to_usize(); - input_iter.next_at(txindex).and_then(|(_, value)| { - let input = value.into_owned(); - if input.is_zero() { - return Some(Sats::ZERO); - } - output_iter.next_at(txindex).map(|(_, value)| { - let output = value.into_owned(); - input.checked_sub(output).unwrap() - }) - }) - }, + Format::Compressed, )?; - let txindex_to_feerate = ComputedVecFrom2::forced_import_or_init_from_2( - Computation::Eager, + let txindex_to_feerate = EagerVec::forced_import( &db, "feerate", version + VERSION + Version::ZERO, - format, - txindex_to_fee.boxed_clone(), - txindex_to_vsize.boxed_clone(), - |txindex: TxIndex, fee_iter, vsize_iter| { - let txindex = txindex.unwrap_to_usize(); - fee_iter.next_at(txindex).and_then(|(_, value)| { - let fee = value.into_owned(); - vsize_iter.next_at(txindex).map(|(_, value)| { - let vsize = value.into_owned(); - Feerate::from((fee, vsize)) - }) - }) - }, + Format::Compressed, )?; Ok(Self { @@ -339,8 +280,6 @@ impl Vecs { "tx_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -355,7 +294,6 @@ impl Vecs { Source::None, version + VERSION + Version::ZERO, format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -370,7 +308,6 @@ impl Vecs { Source::None, version + VERSION + Version::ZERO, format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -384,8 +321,6 @@ impl Vecs { "tx_v1", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -394,8 +329,6 @@ impl Vecs { "tx_v2", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -404,8 +337,6 @@ impl Vecs { "tx_v3", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_sum().add_cumulative(), )?, @@ -415,7 +346,6 @@ impl Vecs { indexes, Source::Vec(txindex_to_fee.boxed_clone()), version + VERSION + Version::ZERO, - computation, format, price, VecBuilderOptions::default() @@ -431,7 +361,6 @@ impl Vecs { Source::None, version + VERSION + Version::ZERO, format, - computation, indexes, VecBuilderOptions::default() .add_percentiles() @@ -444,7 +373,6 @@ impl Vecs { Source::None, version + VERSION + Version::ZERO, format, - computation, indexes, VecBuilderOptions::default() .add_percentiles() @@ -457,7 +385,6 @@ impl Vecs { Source::None, version + VERSION + Version::ZERO, format, - computation, indexes, VecBuilderOptions::default() .add_percentiles() @@ -469,8 +396,6 @@ impl Vecs { "subsidy", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default() .add_percentiles() .add_sum() @@ -485,8 +410,6 @@ impl Vecs { "coinbase", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default() .add_sum() .add_cumulative() @@ -501,8 +424,6 @@ impl Vecs { "unclaimed_rewards", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, VecBuilderOptions::default().add_sum().add_cumulative(), compute_dollars, indexes, @@ -512,8 +433,6 @@ impl Vecs { "p2a_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -527,8 +446,6 @@ impl Vecs { "p2ms_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -542,8 +459,6 @@ impl Vecs { "p2pk33_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -557,8 +472,6 @@ impl Vecs { "p2pk65_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -572,8 +485,6 @@ impl Vecs { "p2pkh_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -587,8 +498,6 @@ impl Vecs { "p2sh_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -602,8 +511,6 @@ impl Vecs { "p2tr_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -617,8 +524,6 @@ impl Vecs { "p2wpkh_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -632,8 +537,6 @@ impl Vecs { "p2wsh_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -647,8 +550,6 @@ impl Vecs { "opreturn_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -662,8 +563,6 @@ impl Vecs { "unknownoutput_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -677,8 +576,6 @@ impl Vecs { "emptyoutput_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default() .add_average() @@ -692,8 +589,6 @@ impl Vecs { "exact_utxo_count", Source::Compute, version + VERSION + Version::ZERO, - format, - computation, indexes, VecBuilderOptions::default().add_last(), )?, @@ -792,36 +687,6 @@ impl Vecs { compute_indexes_to_tx_vany(&mut self.indexes_to_tx_v2, TxVersion::TWO)?; compute_indexes_to_tx_vany(&mut self.indexes_to_tx_v3, TxVersion::THREE)?; - self.txindex_to_is_coinbase.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - - self.txindex_to_weight.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - - self.txindex_to_vsize.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - - self.inputindex_to_value.compute_if_necessary( - starting_indexes.inputindex, - &indexer.vecs.inputindex_to_outputindex, - exit, - )?; - - self.txindex_to_output_value.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - // self.indexes_to_output_value.compute_all( // indexer, // indexes, @@ -838,12 +703,6 @@ impl Vecs { // }, // )?; - self.txindex_to_input_value.compute_if_necessary( - starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, - exit, - )?; - // self.indexes_to_input_value.compute_all( // indexer, // indexes, @@ -860,15 +719,18 @@ impl Vecs { // }, // )?; - self.txindex_to_fee.compute_if_necessary( + self.txindex_to_fee.compute_subtract( starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, + &self.txindex_to_input_value, + &self.txindex_to_output_value, exit, )?; - self.txindex_to_feerate.compute_if_necessary( + self.txindex_to_feerate.compute_transform2( starting_indexes.txindex, - &indexer.vecs.txindex_to_txid, + &self.txindex_to_fee, + &self.txindex_to_vsize, + |(txindex, fee, vsize, ..)| (txindex, Feerate::from((fee, vsize))), exit, )?; diff --git a/crates/brk_structs/src/structs/feerate.rs b/crates/brk_structs/src/structs/feerate.rs index 39e084fc3..53906bd36 100644 --- a/crates/brk_structs/src/structs/feerate.rs +++ b/crates/brk_structs/src/structs/feerate.rs @@ -12,22 +12,24 @@ use super::{Sats, StoredU64}; #[derive( Debug, Clone, Copy, Serialize, FromBytes, Immutable, IntoBytes, KnownLayout, StoredCompressed, )] -pub struct Feerate(f32); +pub struct Feerate(f64); impl From<(Sats, StoredU64)> for Feerate { fn from((sats, vsize): (Sats, StoredU64)) -> Self { - Self((f64::from(sats) / f64::from(vsize)) as f32) + let sats = u64::from(sats); + let vsize = u64::from(vsize); + Self(((sats * 1000 + vsize.checked_sub(1).unwrap()) / vsize) as f64 / 1000.0) } } impl From for Feerate { fn from(value: f64) -> Self { - Self(value as f32) + Self(value) } } impl From for f64 { fn from(value: Feerate) -> Self { - value.0 as f64 + value.0 } } @@ -47,13 +49,13 @@ impl AddAssign for Feerate { impl Div for Feerate { type Output = Self; fn div(self, rhs: usize) -> Self::Output { - Self((self.0 as f64 / rhs as f64) as f32) + Self(self.0 / rhs as f64) } } impl From for Feerate { fn from(value: usize) -> Self { - Self(value as f32) + Self(value as f64) } }