diff --git a/Cargo.lock b/Cargo.lock index 5e196e85a..b2358c3f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1713,13 +1713,13 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1827,9 +1827,9 @@ dependencies = [ [[package]] name = "oxc-miette" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8c278d00ecc50ee84aba4768a7ab74eb325dff4dca8c0581495b850d53480ba" +checksum = "98b2c44324a4372caf6e3128a22744263c973e809fc598db3749ef3ff5e9fed4" dependencies = [ "cfg-if", "owo-colors", @@ -1841,9 +1841,9 @@ dependencies = [ [[package]] name = "oxc-miette-derive" -version = "2.1.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0c893f53900e3fe01eca3d6d3b54085573c3e48fe25af9d57dd94ef600dcd3" +checksum = "3bd3da01a295024fa79e3b4aba14b590d91256a274ff29cc5ee8f55183b2df24" dependencies = [ "proc-macro2", "quote", @@ -2951,9 +2951,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.45.0" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" +checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" dependencies = [ "backtrace", "bytes", diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index 672478b3c..f017fb506 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -9,7 +9,7 @@ use brk_exit::Exit; use brk_fetcher::Fetcher; use brk_indexer::Indexer; pub use brk_parser::rpc; -use brk_vec::{AnyCollectableVec, Compressed, Computation}; +use brk_vec::{AnyCollectableVec, Compressed, Computation, Version}; mod states; mod stores; @@ -29,6 +29,8 @@ pub struct Computer { compressed: Compressed, } +const VERSION: Version = Version::ONE; + impl Computer { pub fn new(outputs_dir: &Path, fetcher: Option, compressed: bool) -> Self { Self { @@ -47,6 +49,7 @@ impl Computer { ) -> color_eyre::Result<()> { self.vecs = Some(Vecs::import( &self.path.join("vecs/computed"), + VERSION + Version::ZERO, indexer, self.fetcher.is_some(), computation, @@ -60,6 +63,7 @@ impl Computer { pub fn import_stores(&mut self, indexer: &Indexer) -> color_eyre::Result<()> { self.stores = Some(Stores::import( &self.path.join("stores"), + VERSION + Version::ZERO, indexer.keyspace(), )?); Ok(()) diff --git a/crates/brk_computer/src/states/cohort.rs b/crates/brk_computer/src/states/cohort.rs index 26f9196be..e46b0a1d5 100644 --- a/crates/brk_computer/src/states/cohort.rs +++ b/crates/brk_computer/src/states/cohort.rs @@ -24,4 +24,8 @@ impl CohortState { realized.decrement(supply_state, price.unwrap()); } } + + pub fn send(&mut self, supply_state: &SupplyState, price: Option) {} + + pub fn receive(&mut self, supply_state: &SupplyState, price: Option) {} } diff --git a/crates/brk_computer/src/states/realized.rs b/crates/brk_computer/src/states/realized.rs index b2d160c86..f824982a4 100644 --- a/crates/brk_computer/src/states/realized.rs +++ b/crates/brk_computer/src/states/realized.rs @@ -5,12 +5,12 @@ use super::SupplyState; #[derive(Debug, Default, Clone)] pub struct RealizedState { pub realized_cap: Dollars, - // pub realized_profit: Dollars, - // pub realized_loss: Dollars, - // pub value_created: Dollars, - // pub adjusted_value_created: Dollars, - // pub value_destroyed: Dollars, - // pub adjusted_value_destroyed: Dollars, + // pub realized_profit: Dollars, // sent price vs now price + // pub realized_loss: Dollars, // sent price vs now price + // pub value_created: Dollars, // supply * price now + // pub adjusted_value_created: Dollars, // supply - up to 1 hour supply * price now + // pub value_destroyed: Dollars, // supply * price then + // pub adjusted_value_destroyed: Dollars, // supply - up to 1 hour supply * price then } impl RealizedState { diff --git a/crates/brk_computer/src/stores.rs b/crates/brk_computer/src/stores.rs index 4e4c6aff7..45bd5ce3d 100644 --- a/crates/brk_computer/src/stores.rs +++ b/crates/brk_computer/src/stores.rs @@ -1,7 +1,10 @@ use std::path::Path; +use brk_vec::Version; use fjall::TransactionalKeyspace; +const _VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Stores { // pub address_to_utxos_received: Store, @@ -9,18 +12,18 @@ pub struct Stores { } impl Stores { - pub fn import(_: &Path, _: &TransactionalKeyspace) -> color_eyre::Result { + pub fn import(_: &Path, _: Version, _: &TransactionalKeyspace) -> color_eyre::Result { // let address_to_utxos_received = Store::import( // keyspace.clone(), // path, // "address_to_utxos_received", - // Version::ZERO, + // version + VERSION + Version::ZERO, // )?; // let address_to_utxos_spent = Store::import( // keyspace.clone(), // path, // "address_to_utxos_spent", - // Version::ZERO, + // version + VERSION + Version::ZERO, // )?; Ok(Self { diff --git a/crates/brk_computer/src/vecs/blocks.rs b/crates/brk_computer/src/vecs/blocks.rs index 0fb043ed1..8aeb06186 100644 --- a/crates/brk_computer/src/vecs/blocks.rs +++ b/crates/brk_computer/src/vecs/blocks.rs @@ -15,6 +15,8 @@ use super::{ indexes, }; +const VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Vecs { pub height_to_interval: EagerVec, @@ -32,6 +34,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import( path: &Path, + version: Version, _computation: Computation, compressed: Compressed, ) -> color_eyre::Result { @@ -41,13 +44,13 @@ impl Vecs { height_to_interval: EagerVec::forced_import( path, "interval", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, timeindexes_to_timestamp: ComputedVecsFromDateIndex::forced_import( path, "timestamp", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_first(), )?, @@ -55,7 +58,7 @@ impl Vecs { path, "block_interval", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_percentiles() @@ -66,7 +69,7 @@ impl Vecs { path, "block_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, @@ -74,7 +77,7 @@ impl Vecs { path, "block_weight", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, @@ -82,29 +85,34 @@ impl Vecs { path, "block_size", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, - height_to_vbytes: EagerVec::forced_import(path, "vbytes", Version::ZERO, compressed)?, + height_to_vbytes: EagerVec::forced_import( + path, + "vbytes", + version + VERSION + Version::ZERO, + compressed, + )?, indexes_to_block_vbytes: ComputedVecsFromHeight::forced_import( path, "block_vbytes", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, difficultyepoch_to_timestamp: EagerVec::forced_import( path, "timestamp", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, halvingepoch_to_timestamp: EagerVec::forced_import( path, "timestamp", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, }) diff --git a/crates/brk_computer/src/vecs/constants.rs b/crates/brk_computer/src/vecs/constants.rs index 09f682f1f..1a48a8b21 100644 --- a/crates/brk_computer/src/vecs/constants.rs +++ b/crates/brk_computer/src/vecs/constants.rs @@ -11,6 +11,8 @@ use super::{ indexes, }; +const VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Vecs { pub _0: ComputedVecsFromHeight, @@ -22,6 +24,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import( path: &Path, + version: Version, _computation: Computation, compressed: Compressed, ) -> color_eyre::Result { @@ -32,7 +35,7 @@ impl Vecs { path, "0", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -40,7 +43,7 @@ impl Vecs { path, "1", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -48,7 +51,7 @@ impl Vecs { path, "50", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -56,7 +59,7 @@ impl Vecs { path, "100", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, diff --git a/crates/brk_computer/src/vecs/fetched.rs b/crates/brk_computer/src/vecs/fetched.rs index 8b0fc2c6d..5a853be6e 100644 --- a/crates/brk_computer/src/vecs/fetched.rs +++ b/crates/brk_computer/src/vecs/fetched.rs @@ -66,11 +66,12 @@ pub struct Vecs { } const VERSION: Version = Version::ZERO; -const VERSION_IN_SATS: Version = Version::ONE; +const VERSION_IN_SATS: Version = Version::ZERO; impl Vecs { pub fn forced_import( path: &Path, + version: Version, _computation: Computation, compressed: Compressed, ) -> color_eyre::Result { @@ -84,236 +85,271 @@ impl Vecs { dateindex_to_ohlc_in_cents: EagerVec::forced_import( &fetched_path, "ohlc_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, + compressed, + )?, + dateindex_to_ohlc: EagerVec::forced_import( + path, + "ohlc", + version + VERSION + Version::ZERO, compressed, )?, - dateindex_to_ohlc: EagerVec::forced_import(path, "ohlc", Version::ZERO, compressed)?, dateindex_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, )?, dateindex_to_close_in_cents: EagerVec::forced_import( path, "close_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, dateindex_to_high_in_cents: EagerVec::forced_import( path, "high_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, dateindex_to_low_in_cents: EagerVec::forced_import( path, "low_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, dateindex_to_open_in_cents: EagerVec::forced_import( path, "open_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_ohlc_in_cents: EagerVec::forced_import( &fetched_path, "ohlc_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, + compressed, + )?, + height_to_ohlc: EagerVec::forced_import( + path, + "ohlc", + version + VERSION + Version::ZERO, compressed, )?, - height_to_ohlc: EagerVec::forced_import(path, "ohlc", Version::ZERO, compressed)?, height_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, )?, height_to_close_in_cents: EagerVec::forced_import( path, "close_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_high_in_cents: EagerVec::forced_import( path, "high_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_low_in_cents: EagerVec::forced_import( path, "low_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_open_in_cents: EagerVec::forced_import( path, "open_in_cents", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, timeindexes_to_open: ComputedVecsFromDateIndex::forced_import( path, "open", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_first(), )?, timeindexes_to_high: ComputedVecsFromDateIndex::forced_import( path, "high", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_max(), )?, timeindexes_to_low: ComputedVecsFromDateIndex::forced_import( path, "low", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_min(), )?, timeindexes_to_close: ComputedVecsFromDateIndex::forced_import( path, "close", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, timeindexes_to_open_in_sats: ComputedVecsFromDateIndex::forced_import( path, "open_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_first(), )?, timeindexes_to_high_in_sats: ComputedVecsFromDateIndex::forced_import( path, "high_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_max(), )?, timeindexes_to_low_in_sats: ComputedVecsFromDateIndex::forced_import( path, "low_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_min(), )?, timeindexes_to_close_in_sats: ComputedVecsFromDateIndex::forced_import( path, "close_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, chainindexes_to_open: ComputedVecsFromHeightStrict::forced_import( path, "open", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_first(), )?, chainindexes_to_high: ComputedVecsFromHeightStrict::forced_import( path, "high", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_max(), )?, chainindexes_to_low: ComputedVecsFromHeightStrict::forced_import( path, "low", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_min(), )?, chainindexes_to_close: ComputedVecsFromHeightStrict::forced_import( path, "close", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, chainindexes_to_open_in_sats: ComputedVecsFromHeightStrict::forced_import( path, "open_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_first(), )?, chainindexes_to_high_in_sats: ComputedVecsFromHeightStrict::forced_import( path, "high_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_max(), )?, chainindexes_to_low_in_sats: ComputedVecsFromHeightStrict::forced_import( path, "low_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_min(), )?, chainindexes_to_close_in_sats: ComputedVecsFromHeightStrict::forced_import( path, "close_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, - weekindex_to_ohlc: EagerVec::forced_import(path, "ohlc", Version::ZERO, compressed)?, + weekindex_to_ohlc: EagerVec::forced_import( + path, + "ohlc", + version + VERSION + Version::ZERO, + compressed, + )?, weekindex_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, )?, difficultyepoch_to_ohlc: EagerVec::forced_import( path, "ohlc", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, difficultyepoch_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, + compressed, + )?, + monthindex_to_ohlc: EagerVec::forced_import( + path, + "ohlc", + version + VERSION + Version::ZERO, compressed, )?, - monthindex_to_ohlc: EagerVec::forced_import(path, "ohlc", Version::ZERO, compressed)?, monthindex_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, + compressed, + )?, + quarterindex_to_ohlc: EagerVec::forced_import( + path, + "ohlc", + version + VERSION + Version::ZERO, compressed, )?, - quarterindex_to_ohlc: EagerVec::forced_import(path, "ohlc", Version::ZERO, compressed)?, quarterindex_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, + compressed, + )?, + yearindex_to_ohlc: EagerVec::forced_import( + path, + "ohlc", + version + VERSION + Version::ZERO, compressed, )?, - yearindex_to_ohlc: EagerVec::forced_import(path, "ohlc", Version::ZERO, compressed)?, yearindex_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, )?, // halvingepoch_to_ohlc: StorableVec::forced_import(path, - // "halvingepoch_to_ohlc"), Version::ZERO, compressed)?, - decadeindex_to_ohlc: EagerVec::forced_import(path, "ohlc", Version::ZERO, compressed)?, + // "halvingepoch_to_ohlc"), version + VERSION + Version::ZERO, compressed)?, + decadeindex_to_ohlc: EagerVec::forced_import( + path, + "ohlc", + version + VERSION + Version::ZERO, + compressed, + )?, decadeindex_to_ohlc_in_sats: EagerVec::forced_import( path, "ohlc_in_sats", - VERSION + VERSION_IN_SATS + Version::ZERO, + version + VERSION + VERSION_IN_SATS + Version::ZERO, compressed, )?, }) diff --git a/crates/brk_computer/src/vecs/grouped/builder.rs b/crates/brk_computer/src/vecs/grouped/builder.rs index bfcf7fb4f..3bb04a0e1 100644 --- a/crates/brk_computer/src/vecs/grouped/builder.rs +++ b/crates/brk_computer/src/vecs/grouped/builder.rs @@ -68,15 +68,13 @@ where } }; - let version = VERSION + version; - let s = Self { first: options.first.then(|| { Box::new( EagerVec::forced_import( path, &maybe_prefix("first"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -93,7 +91,7 @@ where EagerVec::forced_import( path, &maybe_suffix("min"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -104,7 +102,7 @@ where EagerVec::forced_import( path, &maybe_suffix("max"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -115,7 +113,7 @@ where EagerVec::forced_import( path, &maybe_suffix("median"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -126,7 +124,7 @@ where EagerVec::forced_import( path, &maybe_suffix("average"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -137,7 +135,7 @@ where EagerVec::forced_import( path, &maybe_suffix("sum"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -148,7 +146,7 @@ where EagerVec::forced_import( path, &prefix("total"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -159,7 +157,7 @@ where EagerVec::forced_import( path, &maybe_suffix("90p"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -170,7 +168,7 @@ where EagerVec::forced_import( path, &maybe_suffix("75p"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -181,7 +179,7 @@ where EagerVec::forced_import( path, &maybe_suffix("25p"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), @@ -192,7 +190,7 @@ where EagerVec::forced_import( path, &maybe_suffix("10p"), - version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, ) .unwrap(), diff --git a/crates/brk_computer/src/vecs/grouped/from_dateindex.rs b/crates/brk_computer/src/vecs/grouped/from_dateindex.rs index 9313ec870..9b53d2dc3 100644 --- a/crates/brk_computer/src/vecs/grouped/from_dateindex.rs +++ b/crates/brk_computer/src/vecs/grouped/from_dateindex.rs @@ -36,12 +36,10 @@ where compressed: Compressed, options: StorableVecGeneatorOptions, ) -> color_eyre::Result { - let version = VERSION + version; - let dateindex_extra = ComputedVecBuilder::forced_import( path, name, - version, + version + VERSION + Version::ZERO, compressed, options.copy_self_extra(), )?; @@ -49,18 +47,47 @@ where let options = options.remove_percentiles(); Ok(Self { - dateindex: EagerVec::forced_import(path, name, version, compressed)?, + dateindex: EagerVec::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + )?, dateindex_extra, - weekindex: ComputedVecBuilder::forced_import(path, name, version, compressed, options)?, + weekindex: ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?, monthindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, quarterindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?, + yearindex: ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, - yearindex: ComputedVecBuilder::forced_import(path, name, version, compressed, options)?, decadeindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, }) } diff --git a/crates/brk_computer/src/vecs/grouped/from_height.rs b/crates/brk_computer/src/vecs/grouped/from_height.rs index 209646a05..1d449c71c 100644 --- a/crates/brk_computer/src/vecs/grouped/from_height.rs +++ b/crates/brk_computer/src/vecs/grouped/from_height.rs @@ -43,21 +43,28 @@ where compressed: Compressed, options: StorableVecGeneatorOptions, ) -> color_eyre::Result { - let version = VERSION + version; - - let height = compute_source - .then(|| Box::new(EagerVec::forced_import(path, name, version, compressed).unwrap())); + let height = compute_source.then(|| { + Box::new( + EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, compressed) + .unwrap(), + ) + }); let height_extra = ComputedVecBuilder::forced_import( path, name, - version, + version + VERSION + Version::ZERO, compressed, options.copy_self_extra(), )?; - let dateindex = - ComputedVecBuilder::forced_import(path, name, version, compressed, options)?; + let dateindex = ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?; let options = options.remove_percentiles(); @@ -65,20 +72,48 @@ where height, height_extra, dateindex, - weekindex: ComputedVecBuilder::forced_import(path, name, version, compressed, options)?, + weekindex: ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?, difficultyepoch: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, monthindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, quarterindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, - yearindex: ComputedVecBuilder::forced_import(path, name, version, compressed, options)?, - // halvingepoch: StorableVecGeneator::forced_import(path, name, version, compressed, options)?, + yearindex: ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?, + // halvingepoch: StorableVecGeneator::forced_import(path, name, version + VERSION + Version::ZERO, compressed, options)?, decadeindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, }) } diff --git a/crates/brk_computer/src/vecs/grouped/from_height_strict.rs b/crates/brk_computer/src/vecs/grouped/from_height_strict.rs index 31c54e4f3..26f5b9805 100644 --- a/crates/brk_computer/src/vecs/grouped/from_height_strict.rs +++ b/crates/brk_computer/src/vecs/grouped/from_height_strict.rs @@ -34,14 +34,13 @@ where compressed: Compressed, options: StorableVecGeneatorOptions, ) -> color_eyre::Result { - let version = VERSION + version; - - let height = EagerVec::forced_import(path, name, version, compressed)?; + let height = + EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, compressed)?; let height_extra = ComputedVecBuilder::forced_import( path, name, - version, + version + VERSION + Version::ZERO, compressed, options.copy_self_extra(), )?; @@ -52,9 +51,13 @@ where height, height_extra, difficultyepoch: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, - // halvingepoch: StorableVecGeneator::forced_import(path, name, version, compressed, options)?, + // halvingepoch: StorableVecGeneator::forced_import(path, name, version + VERSION + Version::ZERO, compressed, options)?, }) } diff --git a/crates/brk_computer/src/vecs/grouped/from_txindex.rs b/crates/brk_computer/src/vecs/grouped/from_txindex.rs index 1e1c34cfa..40479253f 100644 --- a/crates/brk_computer/src/vecs/grouped/from_txindex.rs +++ b/crates/brk_computer/src/vecs/grouped/from_txindex.rs @@ -47,33 +47,75 @@ where compressed: Compressed, options: StorableVecGeneatorOptions, ) -> color_eyre::Result { - let version = VERSION + version; + let txindex = compute_source.then(|| { + Box::new( + EagerVec::forced_import(path, name, version + VERSION + Version::ZERO, compressed) + .unwrap(), + ) + }); - let txindex = compute_source - .then(|| Box::new(EagerVec::forced_import(path, name, version, compressed).unwrap())); - - let height = ComputedVecBuilder::forced_import(path, name, version, compressed, options)?; + let height = ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?; let options = options.remove_percentiles(); Ok(Self { txindex, height, - dateindex: ComputedVecBuilder::forced_import(path, name, version, compressed, options)?, - weekindex: ComputedVecBuilder::forced_import(path, name, version, compressed, options)?, + dateindex: ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?, + weekindex: ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?, difficultyepoch: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, monthindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, quarterindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, - yearindex: ComputedVecBuilder::forced_import(path, name, version, compressed, options)?, - // halvingepoch: StorableVecGeneator::forced_import(path, name, version, compressed, options)?, + yearindex: ComputedVecBuilder::forced_import( + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, + )?, + // halvingepoch: StorableVecGeneator::forced_import(path, name, version + VERSION + Version::ZERO, compressed, options)?, decadeindex: ComputedVecBuilder::forced_import( - path, name, version, compressed, options, + path, + name, + version + VERSION + Version::ZERO, + compressed, + options, )?, }) } diff --git a/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs b/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs index 937fbceb7..bb871fe3c 100644 --- a/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs +++ b/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs @@ -69,7 +69,7 @@ impl ComputedRatioVecsFromDateIndex { ComputedVecsFromDateIndex::forced_import( path, name, - VERSION + version, + version + VERSION, compressed, options, ) @@ -78,224 +78,224 @@ impl ComputedRatioVecsFromDateIndex { ratio: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_sma: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_sma"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_1w_sma: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_1w_sma"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_1m_sma: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_1m_sma"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_1y_sma: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_1y_sma"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_1y_sma_momentum_oscillator: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_1y_sma_momentum_oscillator"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_standard_deviation: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_standard_deviation"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p99_9: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p99_9"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p99_5: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p99_5"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p99: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p99"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p1: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p1"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p0_5: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p0_5"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p0_1: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p0_1"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p1sd: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p1sd"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p2sd: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p2sd"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p3sd: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p3sd"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_m1sd: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_m1sd"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_m2sd: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_m2sd"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_m3sd: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_m3sd"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p99_9_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p99_9_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p99_5_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p99_5_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p99_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p99_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p1_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p1_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p0_5_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p0_5_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p0_1_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p0_1_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p1sd_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p1sd_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p2sd_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p2sd_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_p3sd_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_p3sd_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_m1sd_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_m1sd_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_m2sd_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_m2sd_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_m3sd_as_price: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_m3sd_as_price"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, ratio_zscore: ComputedVecsFromDateIndex::forced_import( path, &format!("{name}_ratio_zscore"), - VERSION + version + Version::ZERO, + version + VERSION + Version::ZERO, compressed, options, )?, diff --git a/crates/brk_computer/src/vecs/grouped/value_from_height.rs b/crates/brk_computer/src/vecs/grouped/value_from_height.rs index a0ed0ce16..c74000ffa 100644 --- a/crates/brk_computer/src/vecs/grouped/value_from_height.rs +++ b/crates/brk_computer/src/vecs/grouped/value_from_height.rs @@ -18,7 +18,7 @@ pub struct ComputedValueVecsFromHeight { pub dollars: Option>, } -const VERSION: Version = Version::ONE; +const VERSION: Version = Version::ZERO; impl ComputedValueVecsFromHeight { pub fn forced_import( @@ -35,7 +35,7 @@ impl ComputedValueVecsFromHeight { path, name, compute_source, - VERSION + version, + version + VERSION, compressed, options, )?, @@ -43,7 +43,7 @@ impl ComputedValueVecsFromHeight { path, &format!("{name}_in_btc"), true, - VERSION + version, + version + VERSION, compressed, options, )?, @@ -52,7 +52,7 @@ impl ComputedValueVecsFromHeight { path, &format!("{name}_in_usd"), true, - VERSION + version, + version + VERSION, compressed, options, ) diff --git a/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs b/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs index cc3b8b344..22edce0ec 100644 --- a/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs +++ b/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs @@ -33,7 +33,7 @@ pub struct ComputedValueVecsFromTxindex { pub dollars: Option>, } -const VERSION: Version = Version::ONE; +const VERSION: Version = Version::ZERO; impl ComputedValueVecsFromTxindex { #[allow(clippy::too_many_arguments)] @@ -58,14 +58,14 @@ impl ComputedValueVecsFromTxindex { path, name, compute_source, - VERSION + version, + version + VERSION, compressed, options, )?; let bitcoin_txindex = LazyVecFrom1::init( &name_in_btc, - VERSION + version, + version + VERSION, source.map_or_else(|| sats.txindex.as_ref().unwrap().boxed_clone(), |s| s), |txindex: TxIndex, iter| { iter.next_at(txindex.unwrap_to_usize()).map(|(_, value)| { @@ -79,7 +79,7 @@ impl ComputedValueVecsFromTxindex { path, &name_in_btc, false, - VERSION + version, + version + VERSION, compressed, options, )?; @@ -89,7 +89,7 @@ impl ComputedValueVecsFromTxindex { computation, path, &name_in_usd, - VERSION + version, + version + VERSION, compressed, bitcoin_txindex.boxed_clone(), indexes.txindex_to_height.boxed_clone(), @@ -125,7 +125,7 @@ impl ComputedValueVecsFromTxindex { path, &name_in_usd, false, - VERSION + version, + version + VERSION, compressed, options, ) diff --git a/crates/brk_computer/src/vecs/indexes.rs b/crates/brk_computer/src/vecs/indexes.rs index 6864d8486..5320a58d4 100644 --- a/crates/brk_computer/src/vecs/indexes.rs +++ b/crates/brk_computer/src/vecs/indexes.rs @@ -14,6 +14,8 @@ use brk_vec::{ ComputedVecFrom1, ComputedVecFrom2, EagerVec, StoredIndex, VecIterator, Version, }; +const VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Vecs { pub dateindex_to_date: ComputedVecFrom1, @@ -90,6 +92,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import( path: &Path, + version: Version, indexer: &Indexer, computation: Computation, compressed: Compressed, @@ -100,7 +103,7 @@ impl Vecs { computation, path, "outputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().outputindex_to_value.boxed_clone(), |index, _| Some(index), @@ -110,7 +113,7 @@ impl Vecs { computation, path, "inputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().inputindex_to_outputindex.boxed_clone(), |index, _| Some(index), @@ -120,7 +123,7 @@ impl Vecs { computation, path, "txindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().txindex_to_txid.boxed_clone(), |index, _| Some(index), @@ -130,7 +133,7 @@ impl Vecs { computation, path, "input_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().txindex_to_first_inputindex.boxed_clone(), indexer.vecs().inputindex_to_outputindex.boxed_clone(), @@ -153,7 +156,7 @@ impl Vecs { computation, path, "output_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().txindex_to_first_outputindex.boxed_clone(), indexer.vecs().outputindex_to_value.boxed_clone(), @@ -176,7 +179,7 @@ impl Vecs { computation, path, "p2pk33index", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2pk33index_to_p2pk33bytes.boxed_clone(), |index, _| Some(index), @@ -185,7 +188,7 @@ impl Vecs { computation, path, "p2pk65index", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2pk65index_to_p2pk65bytes.boxed_clone(), |index, _| Some(index), @@ -194,7 +197,7 @@ impl Vecs { computation, path, "p2pkhindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2pkhindex_to_p2pkhbytes.boxed_clone(), |index, _| Some(index), @@ -203,7 +206,7 @@ impl Vecs { computation, path, "p2shindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2shindex_to_p2shbytes.boxed_clone(), |index, _| Some(index), @@ -212,7 +215,7 @@ impl Vecs { computation, path, "p2trindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2trindex_to_p2trbytes.boxed_clone(), |index, _| Some(index), @@ -221,7 +224,7 @@ impl Vecs { computation, path, "p2wpkhindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2wpkhindex_to_p2wpkhbytes.boxed_clone(), |index, _| Some(index), @@ -230,7 +233,7 @@ impl Vecs { computation, path, "p2wshindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2wshindex_to_p2wshbytes.boxed_clone(), |index, _| Some(index), @@ -239,7 +242,7 @@ impl Vecs { computation, path, "p2aindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2aindex_to_p2abytes.boxed_clone(), |index, _| Some(index), @@ -248,7 +251,7 @@ impl Vecs { computation, path, "p2msindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().p2msindex_to_txindex.boxed_clone(), |index, _| Some(index), @@ -257,7 +260,7 @@ impl Vecs { computation, path, "emptyoutputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().emptyoutputindex_to_txindex.boxed_clone(), |index, _| Some(index), @@ -266,7 +269,7 @@ impl Vecs { computation, path, "unknownoutputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().unknownoutputindex_to_txindex.boxed_clone(), |index, _| Some(index), @@ -275,20 +278,24 @@ impl Vecs { computation, path, "opreturnindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().opreturnindex_to_txindex.boxed_clone(), |index, _| Some(index), )?; - let dateindex_to_first_height = - EagerVec::forced_import(path, "first_height", Version::ZERO, compressed)?; + let dateindex_to_first_height = EagerVec::forced_import( + path, + "first_height", + version + VERSION + Version::ZERO, + compressed, + )?; let dateindex_to_dateindex = ComputedVec::forced_import_or_init_from_1( computation, path, "dateindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, dateindex_to_first_height.boxed_clone(), |index, _| Some(index), @@ -298,19 +305,20 @@ impl Vecs { computation, path, "date", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, dateindex_to_dateindex.boxed_clone(), |index, _| Some(Date::from(index)), )?; - let height_to_date = EagerVec::forced_import(path, "date", Version::ZERO, compressed)?; + let height_to_date = + EagerVec::forced_import(path, "date", version + VERSION + Version::ZERO, compressed)?; let height_to_height = ComputedVec::forced_import_or_init_from_1( computation, path, "height", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, height_to_date.boxed_clone(), |index, _| Some(index), @@ -320,20 +328,24 @@ impl Vecs { computation, path, "difficultyepoch", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, height_to_height.boxed_clone(), |index, _| Some(DifficultyEpoch::from(index)), )?; - let difficultyepoch_to_first_height = - EagerVec::forced_import(path, "first_height", Version::ZERO, compressed)?; + let difficultyepoch_to_first_height = EagerVec::forced_import( + path, + "first_height", + version + VERSION + Version::ZERO, + compressed, + )?; let difficultyepoch_to_difficultyepoch = ComputedVec::forced_import_or_init_from_1( computation, path, "difficultyepoch", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, difficultyepoch_to_first_height.boxed_clone(), |index, _| Some(index), @@ -343,52 +355,72 @@ impl Vecs { computation, path, "halvingepoch", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, height_to_height.boxed_clone(), |index, _| Some(HalvingEpoch::from(index)), )?; - let halvingepoch_to_first_height = - EagerVec::forced_import(path, "first_height", Version::ZERO, compressed)?; + let halvingepoch_to_first_height = EagerVec::forced_import( + path, + "first_height", + version + VERSION + Version::ZERO, + compressed, + )?; let halvingepoch_to_halvingepoch = ComputedVec::forced_import_or_init_from_1( computation, path, "halvingepoch", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, halvingepoch_to_first_height.boxed_clone(), |index, _| Some(index), )?; - let dateindex_to_weekindex = - EagerVec::forced_import(path, "weekindex", Version::ZERO, compressed)?; + let dateindex_to_weekindex = EagerVec::forced_import( + path, + "weekindex", + version + VERSION + Version::ZERO, + compressed, + )?; - let weekindex_to_first_dateindex = - EagerVec::forced_import(path, "first_dateindex", Version::ZERO, compressed)?; + let weekindex_to_first_dateindex = EagerVec::forced_import( + path, + "first_dateindex", + version + VERSION + Version::ZERO, + compressed, + )?; let weekindex_to_weekindex = ComputedVec::forced_import_or_init_from_1( computation, path, "weekindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, weekindex_to_first_dateindex.boxed_clone(), |index, _| Some(index), )?; - let dateindex_to_monthindex = - EagerVec::forced_import(path, "monthindex", Version::ZERO, compressed)?; + let dateindex_to_monthindex = EagerVec::forced_import( + path, + "monthindex", + version + VERSION + Version::ZERO, + compressed, + )?; - let monthindex_to_first_dateindex = - EagerVec::forced_import(path, "first_dateindex", Version::ZERO, compressed)?; + let monthindex_to_first_dateindex = EagerVec::forced_import( + path, + "first_dateindex", + version + VERSION + Version::ZERO, + compressed, + )?; let monthindex_to_monthindex = ComputedVec::forced_import_or_init_from_1( computation, path, "monthindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, monthindex_to_first_dateindex.boxed_clone(), |index, _| Some(index), @@ -398,20 +430,24 @@ impl Vecs { computation, path, "quarterindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, monthindex_to_monthindex.boxed_clone(), |index, _| Some(QuarterIndex::from(index)), )?; - let quarterindex_to_first_monthindex = - EagerVec::forced_import(path, "first_monthindex", Version::ZERO, compressed)?; + let quarterindex_to_first_monthindex = EagerVec::forced_import( + path, + "first_monthindex", + version + VERSION + Version::ZERO, + compressed, + )?; let quarterindex_to_quarterindex = ComputedVec::forced_import_or_init_from_1( computation, path, "quarterindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, quarterindex_to_first_monthindex.boxed_clone(), |index, _| Some(index), @@ -421,20 +457,24 @@ impl Vecs { computation, path, "yearindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, monthindex_to_monthindex.boxed_clone(), |index, _| Some(YearIndex::from(index)), )?; - let yearindex_to_first_monthindex = - EagerVec::forced_import(path, "first_monthindex", Version::ZERO, compressed)?; + let yearindex_to_first_monthindex = EagerVec::forced_import( + path, + "first_monthindex", + version + VERSION + Version::ZERO, + compressed, + )?; let yearindex_to_yearindex = ComputedVec::forced_import_or_init_from_1( computation, path, "yearindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, yearindex_to_first_monthindex.boxed_clone(), |index, _| Some(index), @@ -444,20 +484,24 @@ impl Vecs { computation, path, "decadeindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, yearindex_to_yearindex.boxed_clone(), |index, _| Some(DecadeIndex::from(index)), )?; - let decadeindex_to_first_yearindex = - EagerVec::forced_import(path, "first_yearindex", Version::ZERO, compressed)?; + let decadeindex_to_first_yearindex = EagerVec::forced_import( + path, + "first_yearindex", + version + VERSION + Version::ZERO, + compressed, + )?; let decadeindex_to_decadeindex = ComputedVec::forced_import_or_init_from_1( computation, path, "decadeindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, decadeindex_to_first_yearindex.boxed_clone(), |index, _| Some(index), @@ -510,74 +554,79 @@ impl Vecs { height_to_date_fixed: EagerVec::forced_import( path, "date_fixed", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_dateindex: EagerVec::forced_import( path, "dateindex", - Version::ZERO, + version + VERSION + Version::ZERO, + compressed, + )?, + txindex_to_height: EagerVec::forced_import( + path, + "height", + version + VERSION + Version::ZERO, compressed, )?, - txindex_to_height: EagerVec::forced_import(path, "height", Version::ZERO, compressed)?, height_to_timestamp_fixed: EagerVec::forced_import( path, "timestamp_fixed", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_txindex_count: EagerVec::forced_import( path, "txindex_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, dateindex_to_height_count: EagerVec::forced_import( path, "height_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, weekindex_to_dateindex_count: EagerVec::forced_import( path, "dateindex_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, difficultyepoch_to_height_count: EagerVec::forced_import( path, "height_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, monthindex_to_dateindex_count: EagerVec::forced_import( path, "dateindex_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, quarterindex_to_monthindex_count: EagerVec::forced_import( path, "monthindex_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, yearindex_to_monthindex_count: EagerVec::forced_import( path, "monthindex_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, decadeindex_to_yearindex_count: EagerVec::forced_import( path, "yearindex_count", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, outputindex_to_txindex: EagerVec::forced_import( path, "txindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, }) diff --git a/crates/brk_computer/src/vecs/market.rs b/crates/brk_computer/src/vecs/market.rs index 7e7cb9718..b1c8d73fb 100644 --- a/crates/brk_computer/src/vecs/market.rs +++ b/crates/brk_computer/src/vecs/market.rs @@ -157,6 +157,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import( path: &Path, + version: Version, _computation: Computation, compressed: Compressed, ) -> color_eyre::Result { @@ -166,42 +167,42 @@ impl Vecs { indexes_to_marketcap: ComputedVecsFromDateIndex::forced_import( path, "marketcap", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, indexes_to_ath: ComputedVecsFromDateIndex::forced_import( path, "ath", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, indexes_to_drawdown: ComputedVecsFromDateIndex::forced_import( path, "drawdown", - Version::ONE, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, indexes_to_days_since_ath: ComputedVecsFromDateIndex::forced_import( path, "days_since_ath", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, indexes_to_max_days_between_ath: ComputedVecsFromDateIndex::forced_import( path, "max_days_between_ath", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, indexes_to_max_years_between_ath: ComputedVecsFromDateIndex::forced_import( path, "max_years_between_ath", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -210,7 +211,7 @@ impl Vecs { path, "1w_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -218,7 +219,7 @@ impl Vecs { path, "8d_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -226,7 +227,7 @@ impl Vecs { path, "13d_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -234,7 +235,7 @@ impl Vecs { path, "21d_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -242,7 +243,7 @@ impl Vecs { path, "1m_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -250,7 +251,7 @@ impl Vecs { path, "34d_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -258,7 +259,7 @@ impl Vecs { path, "55d_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -266,7 +267,7 @@ impl Vecs { path, "89d_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -274,7 +275,7 @@ impl Vecs { path, "144d_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -282,7 +283,7 @@ impl Vecs { path, "1y_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -290,7 +291,7 @@ impl Vecs { path, "2y_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -298,7 +299,7 @@ impl Vecs { path, "200w_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -306,7 +307,7 @@ impl Vecs { path, "4y_sma", true, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -314,140 +315,140 @@ impl Vecs { _1d_returns: ComputedVecsFromDateIndex::forced_import( path, "1d_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1w_returns: ComputedVecsFromDateIndex::forced_import( path, "1w_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1m_returns: ComputedVecsFromDateIndex::forced_import( path, "1m_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3m_returns: ComputedVecsFromDateIndex::forced_import( path, "3m_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6m_returns: ComputedVecsFromDateIndex::forced_import( path, "6m_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1y_returns: ComputedVecsFromDateIndex::forced_import( path, "1y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _2y_returns: ComputedVecsFromDateIndex::forced_import( path, "2y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3y_returns: ComputedVecsFromDateIndex::forced_import( path, "3y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _4y_returns: ComputedVecsFromDateIndex::forced_import( path, "4y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _5y_returns: ComputedVecsFromDateIndex::forced_import( path, "5y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6y_returns: ComputedVecsFromDateIndex::forced_import( path, "6y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _8y_returns: ComputedVecsFromDateIndex::forced_import( path, "8y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _10y_returns: ComputedVecsFromDateIndex::forced_import( path, "10y_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _2y_cagr: ComputedVecsFromDateIndex::forced_import( path, "2y_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3y_cagr: ComputedVecsFromDateIndex::forced_import( path, "3y_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _4y_cagr: ComputedVecsFromDateIndex::forced_import( path, "4y_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _5y_cagr: ComputedVecsFromDateIndex::forced_import( path, "5y_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6y_cagr: ComputedVecsFromDateIndex::forced_import( path, "6y_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _8y_cagr: ComputedVecsFromDateIndex::forced_import( path, "8y_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _10y_cagr: ComputedVecsFromDateIndex::forced_import( path, "10y_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -455,392 +456,392 @@ impl Vecs { _1w_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "1w_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1m_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "1m_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3m_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "3m_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6m_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "6m_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "1y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _2y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "2y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "3y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _4y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "4y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _5y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "5y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "6y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _8y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "8y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _10y_dca_returns: ComputedVecsFromDateIndex::forced_import( path, "10y_dca_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _2y_dca_cagr: ComputedVecsFromDateIndex::forced_import( path, "2y_dca_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3y_dca_cagr: ComputedVecsFromDateIndex::forced_import( path, "3y_dca_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _4y_dca_cagr: ComputedVecsFromDateIndex::forced_import( path, "4y_dca_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _5y_dca_cagr: ComputedVecsFromDateIndex::forced_import( path, "5y_dca_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6y_dca_cagr: ComputedVecsFromDateIndex::forced_import( path, "6y_dca_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _8y_dca_cagr: ComputedVecsFromDateIndex::forced_import( path, "8y_dca_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _10y_dca_cagr: ComputedVecsFromDateIndex::forced_import( path, "10y_dca_cagr", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1w_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "1w_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1m_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "1m_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3m_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "3m_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6m_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "6m_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "1y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _2y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "2y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "3y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _4y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "4y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _5y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "5y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "6y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _8y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "8y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _10y_dca_avg_price: ComputedVecsFromDateIndex::forced_import( path, "10y_dca_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_1d_ago: ComputedVecsFromDateIndex::forced_import( path, "price_1d_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_1w_ago: ComputedVecsFromDateIndex::forced_import( path, "price_1w_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_1m_ago: ComputedVecsFromDateIndex::forced_import( path, "price_1m_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_3m_ago: ComputedVecsFromDateIndex::forced_import( path, "price_3m_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_6m_ago: ComputedVecsFromDateIndex::forced_import( path, "price_6m_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_1y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_1y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_2y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_2y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_3y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_3y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_4y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_4y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_5y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_5y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_6y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_6y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_8y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_8y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, price_10y_ago: ComputedVecsFromDateIndex::forced_import( path, "price_10y_ago", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1w_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "1w_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1m_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "1m_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3m_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "3m_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6m_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "6m_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _1y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "1y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _2y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "2y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _3y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "3y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _4y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "4y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _5y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "5y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _6y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "6y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _8y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "8y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, _10y_dca_stack: ComputedVecsFromDateIndex::forced_import( path, "10y_dca_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -848,77 +849,77 @@ impl Vecs { dca_class_2025_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2025_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2024_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2024_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2023_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2023_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2022_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2022_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2021_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2021_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2020_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2020_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2019_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2019_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2018_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2018_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2017_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2017_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2016_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2016_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2015_stack: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2015_stack", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -926,77 +927,77 @@ impl Vecs { dca_class_2025_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2025_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2024_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2024_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2023_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2023_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2022_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2022_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2021_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2021_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2020_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2020_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2019_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2019_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2018_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2018_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2017_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2017_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2016_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2016_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2015_avg_price: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2015_avg_price", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -1004,77 +1005,77 @@ impl Vecs { dca_class_2025_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2025_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2024_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2024_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2023_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2023_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2022_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2022_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2021_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2021_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2020_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2020_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2019_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2019_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2018_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2018_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2017_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2017_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2016_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2016_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, dca_class_2015_returns: ComputedVecsFromDateIndex::forced_import( path, "dca_class_2015_returns", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, diff --git a/crates/brk_computer/src/vecs/mining.rs b/crates/brk_computer/src/vecs/mining.rs index 15766d77f..44c503492 100644 --- a/crates/brk_computer/src/vecs/mining.rs +++ b/crates/brk_computer/src/vecs/mining.rs @@ -11,6 +11,8 @@ use super::{ indexes, }; +const VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Vecs { pub indexes_to_difficulty: ComputedVecsFromHeight, @@ -21,6 +23,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import( path: &Path, + version: Version, _computation: Computation, compressed: Compressed, ) -> color_eyre::Result { @@ -31,21 +34,21 @@ impl Vecs { path, "difficulty", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, indexes_to_difficultyepoch: ComputedVecsFromDateIndex::forced_import( path, "difficultyepoch", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, indexes_to_halvingepoch: ComputedVecsFromDateIndex::forced_import( path, "halvingepoch", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, diff --git a/crates/brk_computer/src/vecs/mod.rs b/crates/brk_computer/src/vecs/mod.rs index 4f3e48079..b4fe7d683 100644 --- a/crates/brk_computer/src/vecs/mod.rs +++ b/crates/brk_computer/src/vecs/mod.rs @@ -3,7 +3,7 @@ use std::{fs, path::Path}; use brk_exit::Exit; use brk_fetcher::Fetcher; use brk_indexer::Indexer; -use brk_vec::{AnyCollectableVec, Compressed, Computation}; +use brk_vec::{AnyCollectableVec, Compressed, Computation, Version}; pub mod blocks; pub mod constants; @@ -17,6 +17,8 @@ pub mod utxos; pub use indexes::Indexes; +const VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Vecs { pub indexes: indexes::Vecs, @@ -32,6 +34,7 @@ pub struct Vecs { impl Vecs { pub fn import( path: &Path, + version: Version, indexer: &Indexer, fetch: bool, computation: Computation, @@ -39,19 +42,59 @@ impl Vecs { ) -> color_eyre::Result { fs::create_dir_all(path)?; - let indexes = indexes::Vecs::forced_import(path, indexer, computation, compressed)?; + let indexes = indexes::Vecs::forced_import( + path, + version + VERSION + Version::ZERO, + indexer, + computation, + compressed, + )?; - let fetched = - fetch.then(|| fetched::Vecs::forced_import(path, computation, compressed).unwrap()); + let fetched = fetch.then(|| { + fetched::Vecs::forced_import( + path, + version + VERSION + Version::ZERO, + computation, + compressed, + ) + .unwrap() + }); Ok(Self { - blocks: blocks::Vecs::forced_import(path, computation, compressed)?, - mining: mining::Vecs::forced_import(path, computation, compressed)?, - constants: constants::Vecs::forced_import(path, computation, compressed)?, - market: market::Vecs::forced_import(path, computation, compressed)?, - utxos: utxos::Vecs::forced_import(path, computation, compressed, fetched.as_ref())?, + blocks: blocks::Vecs::forced_import( + path, + version + VERSION + Version::ZERO, + computation, + compressed, + )?, + mining: mining::Vecs::forced_import( + path, + version + VERSION + Version::ZERO, + computation, + compressed, + )?, + constants: constants::Vecs::forced_import( + path, + version + VERSION + Version::ZERO, + computation, + compressed, + )?, + market: market::Vecs::forced_import( + path, + version + VERSION + Version::ZERO, + computation, + compressed, + )?, + utxos: utxos::Vecs::forced_import( + path, + version + VERSION + Version::ZERO, + computation, + compressed, + fetched.as_ref(), + )?, transactions: transactions::Vecs::forced_import( path, + version + VERSION + Version::ZERO, indexer, &indexes, computation, diff --git a/crates/brk_computer/src/vecs/transactions.rs b/crates/brk_computer/src/vecs/transactions.rs index 6080c6bb4..b880e5adf 100644 --- a/crates/brk_computer/src/vecs/transactions.rs +++ b/crates/brk_computer/src/vecs/transactions.rs @@ -22,6 +22,8 @@ use super::{ indexes, }; +const VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Vecs { // pub txindex_to_is_v1: LazyVec, @@ -89,6 +91,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import( path: &Path, + version: Version, indexer: &Indexer, indexes: &indexes::Vecs, computation: Computation, @@ -103,7 +106,7 @@ impl Vecs { computation, path, "value", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().inputindex_to_outputindex.boxed_clone(), indexer.vecs().outputindex_to_value.boxed_clone(), @@ -130,7 +133,7 @@ impl Vecs { computation, path, "weight", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().txindex_to_base_size.boxed_clone(), indexer.vecs().txindex_to_total_size.boxed_clone(), @@ -158,7 +161,7 @@ impl Vecs { computation, path, "vsize", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, txindex_to_weight.boxed_clone(), |index: TxIndex, iter| { @@ -175,7 +178,7 @@ impl Vecs { computation, path, "is_coinbase", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexes.txindex_to_height.boxed_clone(), indexer.vecs().height_to_first_txindex.boxed_clone(), @@ -199,7 +202,7 @@ impl Vecs { computation, path, "input_value", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().txindex_to_first_inputindex.boxed_clone(), indexes.txindex_to_input_count.boxed_clone(), @@ -236,7 +239,7 @@ impl Vecs { // path, // "input_value", // true, - // Version::ZERO, + // version + VERSION + Version::ZERO, // compressed, // StorableVecGeneatorOptions::default() // .add_average() @@ -248,7 +251,7 @@ impl Vecs { computation, path, "output_value", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, indexer.vecs().txindex_to_first_outputindex.boxed_clone(), indexes.txindex_to_output_count.boxed_clone(), @@ -285,7 +288,7 @@ impl Vecs { // path, // "output_value", // true, - // Version::ZERO, + // version + VERSION + Version::ZERO, // compressed, // StorableVecGeneatorOptions::default() // .add_average() @@ -297,7 +300,7 @@ impl Vecs { computation, path, "fee", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, txindex_to_input_value.boxed_clone(), txindex_to_output_value.boxed_clone(), @@ -320,7 +323,7 @@ impl Vecs { computation, path, "feerate", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, txindex_to_fee.boxed_clone(), txindex_to_vsize.boxed_clone(), @@ -341,7 +344,7 @@ impl Vecs { path, "tx_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -354,7 +357,7 @@ impl Vecs { path, "input_count", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -367,7 +370,7 @@ impl Vecs { path, "output_count", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -380,7 +383,7 @@ impl Vecs { path, "tx_v1", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, @@ -388,7 +391,7 @@ impl Vecs { path, "tx_v2", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, @@ -396,7 +399,7 @@ impl Vecs { path, "tx_v3", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, @@ -405,7 +408,7 @@ impl Vecs { "fee", indexes, Some(txindex_to_fee.boxed_clone()), - Version::ZERO, + version + VERSION + Version::ZERO, computation, compressed, fetched, @@ -420,7 +423,7 @@ impl Vecs { path, "feerate", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_percentiles() @@ -431,7 +434,7 @@ impl Vecs { path, "tx_vsize", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_percentiles() @@ -442,7 +445,7 @@ impl Vecs { path, "tx_weight", false, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_percentiles() @@ -453,7 +456,7 @@ impl Vecs { path, "subsidy", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_percentiles() @@ -467,7 +470,7 @@ impl Vecs { path, "coinbase", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_sum() @@ -481,7 +484,7 @@ impl Vecs { path, "unclaimed_rewards", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), compute_dollars, @@ -490,7 +493,7 @@ impl Vecs { path, "p2a_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -503,7 +506,7 @@ impl Vecs { path, "p2ms_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -516,7 +519,7 @@ impl Vecs { path, "p2pk33_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -529,7 +532,7 @@ impl Vecs { path, "p2pk65_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -542,7 +545,7 @@ impl Vecs { path, "p2pkh_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -555,7 +558,7 @@ impl Vecs { path, "p2sh_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -568,7 +571,7 @@ impl Vecs { path, "p2tr_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -581,7 +584,7 @@ impl Vecs { path, "p2wpkh_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -594,7 +597,7 @@ impl Vecs { path, "p2wsh_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -607,7 +610,7 @@ impl Vecs { path, "opreturn_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -620,7 +623,7 @@ impl Vecs { path, "unknownoutput_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -633,7 +636,7 @@ impl Vecs { path, "emptyoutput_count", true, - Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default() .add_average() @@ -646,7 +649,7 @@ impl Vecs { path, "exact_utxo_count", true, - Version::TWO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, diff --git a/crates/brk_computer/src/vecs/utxos/cohort.rs b/crates/brk_computer/src/vecs/utxos/cohort.rs index 47085576b..78d3b5812 100644 --- a/crates/brk_computer/src/vecs/utxos/cohort.rs +++ b/crates/brk_computer/src/vecs/utxos/cohort.rs @@ -66,7 +66,7 @@ impl Vecs { EagerVec::forced_import( path, &suffix("realized_cap"), - VERSION + Version::ZERO + version, + version + VERSION + Version::ZERO, compressed, ) .unwrap() @@ -76,7 +76,7 @@ impl Vecs { path, &suffix("realized_cap"), false, - VERSION + Version::ZERO + version, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), ) @@ -85,14 +85,14 @@ impl Vecs { height_to_supply: EagerVec::forced_import( path, &suffix("supply"), - VERSION + Version::ZERO + version, + version + VERSION + Version::ZERO, compressed, )?, indexes_to_supply: ComputedValueVecsFromHeight::forced_import( path, &suffix("supply"), false, - VERSION + Version::ZERO + version, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), compute_dollars, @@ -100,14 +100,14 @@ impl Vecs { height_to_utxo_count: EagerVec::forced_import( path, &suffix("utxo_count"), - VERSION + Version::ZERO + version, + version + VERSION + Version::ZERO, compressed, )?, indexes_to_utxo_count: ComputedVecsFromHeight::forced_import( path, &suffix("utxo_count"), false, - VERSION + Version::ZERO + version, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), )?, @@ -117,7 +117,7 @@ impl Vecs { path, &suffix("realized_price"), true, - VERSION + Version::new(2) + version, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), ) @@ -128,7 +128,7 @@ impl Vecs { path, &suffix("realized_price"), false, - VERSION + Version::new(2) + version, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), ) diff --git a/crates/brk_computer/src/vecs/utxos/mod.rs b/crates/brk_computer/src/vecs/utxos/mod.rs index b9385d2d9..6245a04ba 100644 --- a/crates/brk_computer/src/vecs/utxos/mod.rs +++ b/crates/brk_computer/src/vecs/utxos/mod.rs @@ -23,7 +23,7 @@ use super::{ pub mod cohort; -const VERSION: Version = Version::new(999); +const VERSION: Version = Version::ZERO; #[derive(Clone)] pub struct Vecs { @@ -40,6 +40,7 @@ pub struct Vecs { impl Vecs { pub fn forced_import( path: &Path, + version: Version, _computation: Computation, compressed: Compressed, fetched: Option<&fetched::Vecs>, @@ -54,21 +55,21 @@ impl Vecs { chain_state: StoredVec::forced_import( &states_path, "chain", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, height_to_unspendable_supply: EagerVec::forced_import( path, "unspendable_supply", - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, indexes_to_unspendable_supply: ComputedValueVecsFromHeight::forced_import( path, "unspendable_supply", false, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, compressed, StorableVecGeneatorOptions::default().add_last(), compute_dollars, @@ -80,7 +81,7 @@ impl Vecs { None, _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, by_term: OutputsByTerm { @@ -89,7 +90,7 @@ impl Vecs { Some("sth"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, long: cohort::Vecs::forced_import( @@ -97,7 +98,7 @@ impl Vecs { Some("lth"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, }, @@ -107,7 +108,7 @@ impl Vecs { Some("up_to_1d"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1w: cohort::Vecs::forced_import( @@ -115,7 +116,7 @@ impl Vecs { Some("up_to_1w"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1m: cohort::Vecs::forced_import( @@ -123,7 +124,7 @@ impl Vecs { Some("up_to_1m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _2m: cohort::Vecs::forced_import( @@ -131,7 +132,7 @@ impl Vecs { Some("up_to_2m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _3m: cohort::Vecs::forced_import( @@ -139,7 +140,7 @@ impl Vecs { Some("up_to_3m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _4m: cohort::Vecs::forced_import( @@ -147,7 +148,7 @@ impl Vecs { Some("up_to_4m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _5m: cohort::Vecs::forced_import( @@ -155,7 +156,7 @@ impl Vecs { Some("up_to_5m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _6m: cohort::Vecs::forced_import( @@ -163,7 +164,7 @@ impl Vecs { Some("up_to_6m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1y: cohort::Vecs::forced_import( @@ -171,7 +172,7 @@ impl Vecs { Some("up_to_1y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _2y: cohort::Vecs::forced_import( @@ -179,7 +180,7 @@ impl Vecs { Some("up_to_2y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _3y: cohort::Vecs::forced_import( @@ -187,7 +188,7 @@ impl Vecs { Some("up_to_3y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _4y: cohort::Vecs::forced_import( @@ -195,7 +196,7 @@ impl Vecs { Some("up_to_4y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _5y: cohort::Vecs::forced_import( @@ -203,7 +204,7 @@ impl Vecs { Some("up_to_5y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _6y: cohort::Vecs::forced_import( @@ -211,7 +212,7 @@ impl Vecs { Some("up_to_6y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _7y: cohort::Vecs::forced_import( @@ -219,7 +220,7 @@ impl Vecs { Some("up_to_7y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _8y: cohort::Vecs::forced_import( @@ -227,7 +228,7 @@ impl Vecs { Some("up_to_8y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _10y: cohort::Vecs::forced_import( @@ -235,7 +236,7 @@ impl Vecs { Some("up_to_10y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _15y: cohort::Vecs::forced_import( @@ -243,7 +244,7 @@ impl Vecs { Some("up_to_15y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, }, @@ -253,7 +254,7 @@ impl Vecs { Some("from_1d"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1w: cohort::Vecs::forced_import( @@ -261,7 +262,7 @@ impl Vecs { Some("from_1w"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1m: cohort::Vecs::forced_import( @@ -269,7 +270,7 @@ impl Vecs { Some("from_1m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _2m: cohort::Vecs::forced_import( @@ -277,7 +278,7 @@ impl Vecs { Some("from_2m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _3m: cohort::Vecs::forced_import( @@ -285,7 +286,7 @@ impl Vecs { Some("from_3m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _4m: cohort::Vecs::forced_import( @@ -293,7 +294,7 @@ impl Vecs { Some("from_4m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _5m: cohort::Vecs::forced_import( @@ -301,7 +302,7 @@ impl Vecs { Some("from_5m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _6m: cohort::Vecs::forced_import( @@ -309,7 +310,7 @@ impl Vecs { Some("from_6m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1y: cohort::Vecs::forced_import( @@ -317,7 +318,7 @@ impl Vecs { Some("from_1y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _2y: cohort::Vecs::forced_import( @@ -325,7 +326,7 @@ impl Vecs { Some("from_2y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _3y: cohort::Vecs::forced_import( @@ -333,7 +334,7 @@ impl Vecs { Some("from_3y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _4y: cohort::Vecs::forced_import( @@ -341,7 +342,7 @@ impl Vecs { Some("from_4y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _5y: cohort::Vecs::forced_import( @@ -349,7 +350,7 @@ impl Vecs { Some("from_5y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _6y: cohort::Vecs::forced_import( @@ -357,7 +358,7 @@ impl Vecs { Some("from_6y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _7y: cohort::Vecs::forced_import( @@ -365,7 +366,7 @@ impl Vecs { Some("from_7y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _8y: cohort::Vecs::forced_import( @@ -373,7 +374,7 @@ impl Vecs { Some("from_8y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _10y: cohort::Vecs::forced_import( @@ -381,7 +382,7 @@ impl Vecs { Some("from_10y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _15y: cohort::Vecs::forced_import( @@ -389,7 +390,7 @@ impl Vecs { Some("from_15y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, }, @@ -399,7 +400,7 @@ impl Vecs { Some("from_1d_to_1w"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1w_to_1m: cohort::Vecs::forced_import( @@ -407,7 +408,7 @@ impl Vecs { Some("from_1w_to_1m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1m_to_3m: cohort::Vecs::forced_import( @@ -415,7 +416,7 @@ impl Vecs { Some("from_1m_to_3m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _3m_to_6m: cohort::Vecs::forced_import( @@ -423,7 +424,7 @@ impl Vecs { Some("from_3m_to_6m"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _6m_to_1y: cohort::Vecs::forced_import( @@ -431,7 +432,7 @@ impl Vecs { Some("from_6m_to_1y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1y_to_2y: cohort::Vecs::forced_import( @@ -439,7 +440,7 @@ impl Vecs { Some("from_1y_to_2y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _2y_to_3y: cohort::Vecs::forced_import( @@ -447,7 +448,7 @@ impl Vecs { Some("from_2y_to_3y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _3y_to_4y: cohort::Vecs::forced_import( @@ -455,7 +456,7 @@ impl Vecs { Some("from_3y_to_4y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _4y_to_5y: cohort::Vecs::forced_import( @@ -463,7 +464,7 @@ impl Vecs { Some("from_4y_to_5y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _5y_to_7y: cohort::Vecs::forced_import( @@ -471,7 +472,7 @@ impl Vecs { Some("from_5y_to_7y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _7y_to_10y: cohort::Vecs::forced_import( @@ -479,7 +480,7 @@ impl Vecs { Some("from_7y_to_10y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _10y_to_15y: cohort::Vecs::forced_import( @@ -487,7 +488,7 @@ impl Vecs { Some("from_10y_to_15y"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, }, @@ -497,7 +498,7 @@ impl Vecs { Some("epoch_0"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _1: cohort::Vecs::forced_import( @@ -505,7 +506,7 @@ impl Vecs { Some("epoch_1"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _2: cohort::Vecs::forced_import( @@ -513,7 +514,7 @@ impl Vecs { Some("epoch_2"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _3: cohort::Vecs::forced_import( @@ -521,7 +522,7 @@ impl Vecs { Some("epoch_3"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, _4: cohort::Vecs::forced_import( @@ -529,7 +530,7 @@ impl Vecs { Some("epoch_4"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, }, @@ -539,7 +540,7 @@ impl Vecs { Some("0sat"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_1sat_to_10sats: cohort::Vecs::forced_import( @@ -547,7 +548,7 @@ impl Vecs { Some("from_1sat_to_10sats"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_10sats_to_100sats: cohort::Vecs::forced_import( @@ -555,7 +556,7 @@ impl Vecs { Some("from_10sats_to_100sats"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_100sats_to_1_000sats: cohort::Vecs::forced_import( @@ -563,7 +564,7 @@ impl Vecs { Some("from_100sats_to_1_000sats"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_1_000sats_to_10_000sats: cohort::Vecs::forced_import( @@ -571,7 +572,7 @@ impl Vecs { Some("from_1_000sats_to_10_000sats"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_10_000sats_to_100_000sats: cohort::Vecs::forced_import( @@ -579,7 +580,7 @@ impl Vecs { Some("from_10_000sats_to_100_000sats"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_100_000sats_to_1_000_000sats: cohort::Vecs::forced_import( @@ -587,7 +588,7 @@ impl Vecs { Some("from_100_000sats_to_1_000_000sats"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_1_000_000sats_to_10_000_000sats: cohort::Vecs::forced_import( @@ -595,7 +596,7 @@ impl Vecs { Some("from_1_000_000sats_to_10_000_000sats"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_10_000_000sats_to_1btc: cohort::Vecs::forced_import( @@ -603,7 +604,7 @@ impl Vecs { Some("from_10_000_000sats_to_1btc"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_1btc_to_10btc: cohort::Vecs::forced_import( @@ -611,7 +612,7 @@ impl Vecs { Some("from_1btc_to_10btc"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_10btc_to_100btc: cohort::Vecs::forced_import( @@ -619,7 +620,7 @@ impl Vecs { Some("from_10btc_to_100btc"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_100btc_to_1_000btc: cohort::Vecs::forced_import( @@ -627,7 +628,7 @@ impl Vecs { Some("from_100btc_to_1_000btc"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_1_000btc_to_10_000btc: cohort::Vecs::forced_import( @@ -635,7 +636,7 @@ impl Vecs { Some("from_1_000btc_to_10_000btc"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_10_000btc_to_100_000btc: cohort::Vecs::forced_import( @@ -643,7 +644,7 @@ impl Vecs { Some("from_10_000btc_to_100_000btc"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, from_100_000btc: cohort::Vecs::forced_import( @@ -651,7 +652,7 @@ impl Vecs { Some("from_100_000btc"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, }, @@ -754,7 +755,7 @@ impl Vecs { Some("p2pk65"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, p2pk33: cohort::Vecs::forced_import( @@ -762,7 +763,7 @@ impl Vecs { Some("p2pk33"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, p2pkh: cohort::Vecs::forced_import( @@ -770,7 +771,7 @@ impl Vecs { Some("p2pkh"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, p2ms: cohort::Vecs::forced_import( @@ -778,7 +779,7 @@ impl Vecs { Some("p2ms"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, p2sh: cohort::Vecs::forced_import( @@ -786,7 +787,7 @@ impl Vecs { Some("p2sh"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, // op_return: cohort::Vecs::forced_import( @@ -802,7 +803,7 @@ impl Vecs { Some("p2wpkh"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, p2wsh: cohort::Vecs::forced_import( @@ -810,7 +811,7 @@ impl Vecs { Some("p2wsh"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, p2tr: cohort::Vecs::forced_import( @@ -818,7 +819,7 @@ impl Vecs { Some("p2tr"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, p2a: cohort::Vecs::forced_import( @@ -826,7 +827,7 @@ impl Vecs { Some("p2a"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, empty: cohort::Vecs::forced_import( @@ -834,7 +835,7 @@ impl Vecs { Some("empty"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, unknown: cohort::Vecs::forced_import( @@ -842,7 +843,7 @@ impl Vecs { Some("unknown"), _computation, compressed, - VERSION + Version::ZERO, + version + VERSION + Version::ZERO, fetched, )?, }, diff --git a/crates/brk_fetcher/src/lib.rs b/crates/brk_fetcher/src/lib.rs index fcffb6325..fbce75a97 100644 --- a/crates/brk_fetcher/src/lib.rs +++ b/crates/brk_fetcher/src/lib.rs @@ -11,6 +11,9 @@ use color_eyre::eyre::Error; mod fetchers; use fetchers::*; +use log::info; + +const TRIES: usize = 12 * 60 * 2; #[derive(Clone)] pub struct Fetcher { @@ -33,16 +36,32 @@ impl Fetcher { } pub fn get_date(&mut self, date: Date) -> color_eyre::Result { + self.get_date_(date, 0) + } + + fn get_date_(&mut self, date: Date, tries: usize) -> color_eyre::Result { self.kraken .get_from_1d(&date) .or_else(|_| { // eprintln!("{e}"); self.binance.get_from_1d(&date) }) - .or_else(|e| { - eprintln!("{e}"); + .or_else(|_| { + // eprintln!("{e}"); self.kibo.get_from_date(&date) }) + .or_else(|e| { + sleep(Duration::from_secs(30)); + + if tries < TRIES { + self.clear(); + info!("Retrying to fetch date price..."); + self.get_date_(date, tries + 1) + } else { + info!("Failed to fetch date prices..."); + Err(e) + } + }) } pub fn get_height( @@ -81,14 +100,18 @@ impl Fetcher { self.kibo.get_from_height(height).unwrap_or_else(|_| { sleep(Duration::from_secs(30)); - if tries < 8 * 60 * 2 { + if tries < TRIES { self.clear(); + info!("Retrying to fetch height prices..."); + return self .get_height_(height, timestamp, previous_timestamp, tries + 1) .unwrap(); } + info!("Failed to fetch height prices"); + let date = Date::from(timestamp); // eprintln!("{e}"); panic!( @@ -112,8 +135,6 @@ How to fix this: }) }); - // self.ohlc.height.insert(height, ohlc); - Ok(ohlc) } diff --git a/crates/brk_indexer/src/lib.rs b/crates/brk_indexer/src/lib.rs index 83cc22ada..0f426bba7 100644 --- a/crates/brk_indexer/src/lib.rs +++ b/crates/brk_indexer/src/lib.rs @@ -18,7 +18,7 @@ pub use brk_parser::*; use bitcoin::{Transaction, TxIn, TxOut}; use brk_exit::Exit; -use brk_vec::{AnyVec, Compressed, VecIterator}; +use brk_vec::{AnyVec, Compressed, VecIterator, Version}; use color_eyre::eyre::{ContextCompat, eyre}; use fjall::TransactionalKeyspace; use log::{error, info}; @@ -33,6 +33,7 @@ pub use vecs::*; const SNAPSHOT_BLOCK_RANGE: usize = 1000; const COLLISIONS_CHECKED_UP_TO: u32 = 893_000; +const VERSION: Version = Version::ONE; #[derive(Clone)] pub struct Indexer { @@ -62,6 +63,7 @@ impl Indexer { pub fn import_vecs(&mut self) -> color_eyre::Result<()> { self.vecs = Some(Vecs::forced_import( &self.path.join("vecs/indexed"), + VERSION + Version::ZERO, self.compressed, )?); Ok(()) @@ -70,7 +72,10 @@ impl Indexer { /// Do NOT import multiple times are things will break !!! /// Clone struct instead pub fn import_stores(&mut self) -> color_eyre::Result<()> { - self.stores = Some(Stores::forced_import(&self.path.join("stores"))?); + self.stores = Some(Stores::forced_import( + &self.path.join("stores"), + VERSION + Version::ZERO, + )?); Ok(()) } diff --git a/crates/brk_indexer/src/stores/base.rs b/crates/brk_indexer/src/stores/base.rs index 024a1f212..65588d3d4 100644 --- a/crates/brk_indexer/src/stores/base.rs +++ b/crates/brk_indexer/src/stores/base.rs @@ -42,12 +42,10 @@ where name: &str, version: Version, ) -> color_eyre::Result { - let version = MAJOR_FJALL_VERSION + version; - let (meta, partition) = StoreMeta::checked_open( &keyspace, &path.join(format!("meta/{name}")), - version, + MAJOR_FJALL_VERSION + version, || { Self::open_partition_handle(&keyspace, name).inspect_err(|_| { eprintln!("Delete {path:?} and try again"); diff --git a/crates/brk_indexer/src/stores/mod.rs b/crates/brk_indexer/src/stores/mod.rs index 06848aad9..2bf548b65 100644 --- a/crates/brk_indexer/src/stores/mod.rs +++ b/crates/brk_indexer/src/stores/mod.rs @@ -25,15 +25,17 @@ pub struct Stores { pub txidprefix_to_txindex: Store, } +const VERSION: Version = Version::ZERO; + impl Stores { - pub fn forced_import(path: &Path) -> color_eyre::Result { + pub fn forced_import(path: &Path, version: Version) -> color_eyre::Result { fs::create_dir_all(path)?; let keyspace = match Self::open_keyspace(path) { Ok(keyspace) => keyspace, Err(_) => { fs::remove_dir_all(path)?; - return Self::forced_import(path); + return Self::forced_import(path, version); } }; @@ -43,7 +45,7 @@ impl Stores { keyspace.clone(), path, "addressbyteshash_to_outputtypeindex", - Version::ZERO, + version + VERSION + Version::ZERO, ) }); let blockhashprefix_to_height = scope.spawn(|| { @@ -51,7 +53,7 @@ impl Stores { keyspace.clone(), path, "blockhashprefix_to_height", - Version::ZERO, + version + VERSION + Version::ZERO, ) }); let txidprefix_to_txindex = scope.spawn(|| { @@ -59,7 +61,7 @@ impl Stores { keyspace.clone(), path, "txidprefix_to_txindex", - Version::ZERO, + version + VERSION + Version::ZERO, ) }); diff --git a/crates/brk_indexer/src/vecs/mod.rs b/crates/brk_indexer/src/vecs/mod.rs index 1d7879bf9..b85e42f80 100644 --- a/crates/brk_indexer/src/vecs/mod.rs +++ b/crates/brk_indexer/src/vecs/mod.rs @@ -12,6 +12,8 @@ use rayon::prelude::*; use crate::Indexes; +const VERSION: Version = Version::ZERO; + #[derive(Clone)] pub struct Vecs { pub emptyoutputindex_to_txindex: IndexedVec, @@ -63,267 +65,276 @@ pub struct Vecs { } impl Vecs { - pub fn forced_import(path: &Path, compressed: Compressed) -> color_eyre::Result { + pub fn forced_import( + path: &Path, + version: Version, + compressed: Compressed, + ) -> color_eyre::Result { fs::create_dir_all(path)?; Ok(Self { emptyoutputindex_to_txindex: IndexedVec::forced_import( path, "txindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_blockhash: IndexedVec::forced_import( path, "blockhash", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, height_to_difficulty: IndexedVec::forced_import( path, "difficulty", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_emptyoutputindex: IndexedVec::forced_import( path, "first_emptyoutputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_inputindex: IndexedVec::forced_import( path, "first_inputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_opreturnindex: IndexedVec::forced_import( path, "first_opreturnindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_outputindex: IndexedVec::forced_import( path, "first_outputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2aindex: IndexedVec::forced_import( path, "first_p2aindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2msindex: IndexedVec::forced_import( path, "first_p2msindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2pk33index: IndexedVec::forced_import( path, "first_p2pk33index", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2pk65index: IndexedVec::forced_import( path, "first_p2pk65index", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2pkhindex: IndexedVec::forced_import( path, "first_p2pkhindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2shindex: IndexedVec::forced_import( path, "first_p2shindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2trindex: IndexedVec::forced_import( path, "first_p2trindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2wpkhindex: IndexedVec::forced_import( path, "first_p2wpkhindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_p2wshindex: IndexedVec::forced_import( path, "first_p2wshindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_txindex: IndexedVec::forced_import( path, "first_txindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_first_unknownoutputindex: IndexedVec::forced_import( path, "first_unknownoutputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_timestamp: IndexedVec::forced_import( path, "timestamp", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, height_to_total_size: IndexedVec::forced_import( path, "total_size", - Version::ZERO, + version + VERSION + Version::ZERO, + compressed, + )?, + height_to_weight: IndexedVec::forced_import( + path, + "weight", + version + VERSION + Version::ZERO, compressed, )?, - height_to_weight: IndexedVec::forced_import(path, "weight", Version::ZERO, compressed)?, inputindex_to_outputindex: IndexedVec::forced_import( path, "outputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, opreturnindex_to_txindex: IndexedVec::forced_import( path, "txindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, outputindex_to_outputtype: IndexedVec::forced_import( path, "outputtype", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, outputindex_to_outputtypeindex: IndexedVec::forced_import( path, "outputtypeindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, outputindex_to_value: IndexedVec::forced_import( path, "value", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, p2aindex_to_p2abytes: IndexedVec::forced_import( path, "p2abytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, p2msindex_to_txindex: IndexedVec::forced_import( path, "txindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, p2pk33index_to_p2pk33bytes: IndexedVec::forced_import( path, "p2pk33bytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, p2pk65index_to_p2pk65bytes: IndexedVec::forced_import( path, "p2pk65bytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, p2pkhindex_to_p2pkhbytes: IndexedVec::forced_import( path, "p2pkhbytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, p2shindex_to_p2shbytes: IndexedVec::forced_import( path, "p2shbytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, p2trindex_to_p2trbytes: IndexedVec::forced_import( path, "p2trbytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, p2wpkhindex_to_p2wpkhbytes: IndexedVec::forced_import( path, "p2wpkhbytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, p2wshindex_to_p2wshbytes: IndexedVec::forced_import( path, "p2wshbytes", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, txindex_to_base_size: IndexedVec::forced_import( path, "base_size", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, txindex_to_first_inputindex: IndexedVec::forced_import( path, "first_inputindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, txindex_to_first_outputindex: IndexedVec::forced_import( path, "first_outputindex", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, txindex_to_is_explicitly_rbf: IndexedVec::forced_import( path, "is_explicitly_rbf", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, txindex_to_rawlocktime: IndexedVec::forced_import( path, "rawlocktime", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, txindex_to_total_size: IndexedVec::forced_import( path, "total_size", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, txindex_to_txid: IndexedVec::forced_import( path, "txid", - Version::ZERO, + version + VERSION + Version::ZERO, Compressed::NO, )?, txindex_to_txversion: IndexedVec::forced_import( path, "txversion", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, unknownoutputindex_to_txindex: IndexedVec::forced_import( path, "txindex", - Version::ZERO, + version + VERSION + Version::ZERO, compressed, )?, }) diff --git a/crates/brk_server/Cargo.toml b/crates/brk_server/Cargo.toml index 056c253c6..263d761ab 100644 --- a/crates/brk_server/Cargo.toml +++ b/crates/brk_server/Cargo.toml @@ -25,7 +25,7 @@ log = { workspace = true } minreq = { workspace = true } oxc = { version = "0.72.0", features = ["codegen", "minifier"] } serde = { workspace = true } -tokio = { version = "1.45.0", features = ["full"] } +tokio = { version = "1.45.1", features = ["full"] } tower-http = { version = "0.6.4", features = ["compression-full", "trace"] } zip = "4.0.0" tracing = "0.1.41" diff --git a/crates/brk_vec/src/structs/version.rs b/crates/brk_vec/src/structs/version.rs index 8c332fc6f..24fc707c5 100644 --- a/crates/brk_vec/src/structs/version.rs +++ b/crates/brk_vec/src/structs/version.rs @@ -13,14 +13,14 @@ use crate::{Error, Result}; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, FromBytes, IntoBytes, Immutable, KnownLayout, )] -pub struct Version(u32); +pub struct Version(u64); impl Version { pub const ZERO: Self = Self(0); pub const ONE: Self = Self(1); pub const TWO: Self = Self(2); - pub const fn new(v: u32) -> Self { + pub const fn new(v: u64) -> Self { Self(v) } @@ -49,8 +49,8 @@ impl Version { } } -impl From for Version { - fn from(value: u32) -> Self { +impl From for Version { + fn from(value: u64) -> Self { Self(value) } } diff --git a/crates/brk_vec/src/variants/eager.rs b/crates/brk_vec/src/variants/eager.rs index 010ed41bb..811eea2cd 100644 --- a/crates/brk_vec/src/variants/eager.rs +++ b/crates/brk_vec/src/variants/eager.rs @@ -783,7 +783,7 @@ impl EagerVec { exit: &Exit, ) -> Result<()> { self.validate_computed_version_or_reset_file( - Version::TWO + self.inner.version() + stacks.version(), + Version::ZERO + self.inner.version() + stacks.version(), )?; let index = max_from.min(DateIndex::from(self.len())); diff --git a/crates/brk_vec/src/variants/stored.rs b/crates/brk_vec/src/variants/stored.rs index 0ec41e4e1..6f24a5051 100644 --- a/crates/brk_vec/src/variants/stored.rs +++ b/crates/brk_vec/src/variants/stored.rs @@ -28,6 +28,12 @@ where compressed: Compressed, ) -> Result { let path = I::path(path, value_name); + + if version == Version::ZERO { + dbg!(path, value_name); + panic!("Version must be at least 1, can't verify endianess otherwise"); + } + if *compressed { Ok(Self::Compressed(CompressedVec::forced_import( &path, version,