diff --git a/TODO.md b/TODO.md index 114220a3c..6e9cbc07a 100644 --- a/TODO.md +++ b/TODO.md @@ -16,13 +16,15 @@ - add oracle price dataset (https://utxo.live/oracle/UTXOracle.py) - add address counts relative to all datasets - make decade, quarter, year datasets `computed` instead of `eager` - - add 6 months interval datasets to builder + - add 6 months (semester) interval datasets to builder - add revived/sent supply datasets - add `in-sats` version of all price datasets (average and co) - add `p2pk` group (sum of `p2pk33` and `p2pk65`) - add more date ranges (3-6 months and more) - add puell multiple dataset - add pi cycle dataset + - add ema of price + - add 7d and 30d ema to sell side risk ratio and sopr - add all possible charts from: - https://mainnet.observer - https://glassnode.com @@ -51,6 +53,7 @@ - _vec_ - add native lock file support (once it's available in stable rust) - improve compressed mode (slow reads) + - add ema support - __docs__ - _README_ - add a comparison table with alternatives diff --git a/crates/brk_computer/src/states/transacted.rs b/crates/brk_computer/src/states/transacted.rs index c9b0fc9ef..64f8c3b73 100644 --- a/crates/brk_computer/src/states/transacted.rs +++ b/crates/brk_computer/src/states/transacted.rs @@ -1,6 +1,6 @@ use std::ops::{Add, AddAssign}; -use brk_core::{GroupedBySizeRange, GroupedByType, OutputType, Sats}; +use brk_core::{ByAmountRange, GroupedByType, OutputType, Sats}; use super::SupplyState; @@ -8,7 +8,7 @@ use super::SupplyState; pub struct Transacted { pub spendable_supply: SupplyState, pub by_type: GroupedByType, - pub by_size_group: GroupedBySizeRange, + pub by_size_group: ByAmountRange, } impl Transacted { diff --git a/crates/brk_computer/src/stores.rs b/crates/brk_computer/src/stores.rs index a254ec656..024752e42 100644 --- a/crates/brk_computer/src/stores.rs +++ b/crates/brk_computer/src/stores.rs @@ -1,7 +1,7 @@ use std::{path::Path, thread}; use brk_core::{ - AddressData, EmptyAddressData, GroupedByAddressType, Height, OutputType, P2AAddressIndex, + AddressData, ByAddressType, EmptyAddressData, Height, OutputType, P2AAddressIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, Result, TypeIndex, Version, }; @@ -375,7 +375,7 @@ impl Stores { WithAddressDataSource, >, ) -> Result<()> { - let GroupedByAddressType { + let ByAddressType { p2pk65, p2pk33, p2pkh, @@ -386,7 +386,7 @@ impl Stores { p2a, } = addresstype_to_typeindex_to_addressdata.unwrap(); - let GroupedByAddressType { + let ByAddressType { p2pk65: empty_p2pk65, p2pk33: empty_p2pk33, p2pkh: empty_p2pkh, diff --git a/crates/brk_computer/src/vecs/fetched.rs b/crates/brk_computer/src/vecs/fetched.rs index 2fdd97e17..6afbdfd91 100644 --- a/crates/brk_computer/src/vecs/fetched.rs +++ b/crates/brk_computer/src/vecs/fetched.rs @@ -7,7 +7,9 @@ use brk_core::{ use brk_exit::Exit; use brk_fetcher::Fetcher; use brk_indexer::Indexer; -use brk_vec::{AnyCollectableVec, AnyIterableVec, Computation, EagerVec, Format, StoredIndex}; +use brk_vec::{ + AnyCollectableVec, AnyIterableVec, AnyVec, Computation, EagerVec, Format, StoredIndex, +}; use super::{ Indexes, @@ -426,7 +428,13 @@ impl Vecs { starting_indexes.dateindex, &indexes.dateindex_to_date, |(di, d, this)| { - let mut ohlc = fetcher.get_date(d).unwrap(); + let mut ohlc = fetcher.get_date(d).unwrap_or_else(|_| { + this.get_or_read(di, &this.mmap().load()) + .unwrap() + .unwrap() + .into_owned() + }); + if let Some(prev) = di.decremented() { let prev_open = *this .get_or_read(prev, &this.mmap().load()) diff --git a/crates/brk_computer/src/vecs/grouped/builder.rs b/crates/brk_computer/src/vecs/grouped/builder.rs index 170bada7a..0a510df57 100644 --- a/crates/brk_computer/src/vecs/grouped/builder.rs +++ b/crates/brk_computer/src/vecs/grouped/builder.rs @@ -45,16 +45,6 @@ where ) -> color_eyre::Result { let only_one_active = options.is_only_one_active(); - let prefix = |s: &str| format!("{s}_{name}"); - - let maybe_prefix = |s: &str| { - if only_one_active { - name.to_string() - } else { - prefix(s) - } - }; - let suffix = |s: &str| format!("{name}_{s}"); let maybe_suffix = |s: &str| { @@ -70,7 +60,7 @@ where Box::new( EagerVec::forced_import( path, - &maybe_prefix("first"), + &maybe_suffix("first"), version + VERSION + Version::ZERO, format, ) @@ -130,7 +120,7 @@ where Box::new( EagerVec::forced_import( path, - &(if !options.last { + &(if !options.last && !options.average && !options.min && !options.max { name.to_string() } else { maybe_suffix("sum") @@ -145,7 +135,7 @@ where Box::new( EagerVec::forced_import( path, - &prefix("cumulative"), + &suffix("cumulative"), version + VERSION + Version::ZERO, format, ) diff --git a/crates/brk_computer/src/vecs/stateful/address_cohorts.rs b/crates/brk_computer/src/vecs/stateful/address_cohorts.rs index 4456e80c5..6512d1567 100644 --- a/crates/brk_computer/src/vecs/stateful/address_cohorts.rs +++ b/crates/brk_computer/src/vecs/stateful/address_cohorts.rs @@ -1,7 +1,7 @@ use std::path::Path; use brk_core::{ - AddressGroups, GroupFilter, GroupedByFromSize, GroupedBySizeRange, GroupedByUpToSize, Height, + AddressGroups, ByAmountRange, ByGreatEqualAmount, ByLowerThanAmount, GroupFilter, Height, Result, Version, }; use brk_exit::Exit; @@ -33,10 +33,10 @@ impl Vecs { ) -> color_eyre::Result { Ok(Self( AddressGroups { - by_size_range: GroupedBySizeRange { + amount_range: ByAmountRange { _0sats: address_cohort::Vecs::forced_import( path, - Some("addresses_0sats"), + Some("addrs_with_0sats"), _computation, format, version + VERSION + Version::ZERO, @@ -44,9 +44,9 @@ impl Vecs { states_path, true, )?, - from_1sat_to_10sats: address_cohort::Vecs::forced_import( + _1sat_to_10sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1sat_to_10sats"), + Some("addrs_above_1sat_under_10sats"), _computation, format, version + VERSION + Version::ZERO, @@ -54,9 +54,9 @@ impl Vecs { states_path, true, )?, - from_10sats_to_100sats: address_cohort::Vecs::forced_import( + _10sats_to_100sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10sats_to_100sats"), + Some("addrs_above_10sats_under_100sats"), _computation, format, version + VERSION + Version::ZERO, @@ -64,9 +64,9 @@ impl Vecs { states_path, true, )?, - from_100sats_to_1_000sats: address_cohort::Vecs::forced_import( + _100sats_to_1k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_100sats_to_1_000sats"), + Some("addrs_above_100sats_under_1k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -74,9 +74,9 @@ impl Vecs { states_path, true, )?, - from_1_000sats_to_10_000sats: address_cohort::Vecs::forced_import( + _1k_sats_to_10k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1_000sats_to_10_000sats"), + Some("addrs_above_1k_sats_under_10k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -84,9 +84,9 @@ impl Vecs { states_path, true, )?, - from_10_000sats_to_100_000sats: address_cohort::Vecs::forced_import( + _10k_sats_to_100k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10_000sats_to_100_000sats"), + Some("addrs_above_10k_sats_under_100k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -94,9 +94,9 @@ impl Vecs { states_path, true, )?, - from_100_000sats_to_1_000_000sats: address_cohort::Vecs::forced_import( + _100k_sats_to_1m_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_100_000sats_to_1_000_000sats"), + Some("addrs_above_100k_sats_under_1m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -104,9 +104,9 @@ impl Vecs { states_path, true, )?, - from_1_000_000sats_to_10_000_000sats: address_cohort::Vecs::forced_import( + _1m_sats_to_10m_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1_000_000sats_to_10_000_000sats"), + Some("addrs_above_1m_sats_under_10m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -114,9 +114,9 @@ impl Vecs { states_path, true, )?, - from_10_000_000sats_to_1btc: address_cohort::Vecs::forced_import( + _10m_sats_to_1btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10_000_000sats_to_1btc"), + Some("addrs_above_10m_sats_under_1btc"), _computation, format, version + VERSION + Version::ZERO, @@ -124,9 +124,9 @@ impl Vecs { states_path, true, )?, - from_1btc_to_10btc: address_cohort::Vecs::forced_import( + _1btc_to_10btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1btc_to_10btc"), + Some("addrs_above_1btc_under_10btc"), _computation, format, version + VERSION + Version::ZERO, @@ -134,9 +134,9 @@ impl Vecs { states_path, true, )?, - from_10btc_to_100btc: address_cohort::Vecs::forced_import( + _10btc_to_100btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10btc_to_100btc"), + Some("addrs_above_10btc_under_100btc"), _computation, format, version + VERSION + Version::ZERO, @@ -144,9 +144,9 @@ impl Vecs { states_path, true, )?, - from_100btc_to_1_000btc: address_cohort::Vecs::forced_import( + _100btc_to_1k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_100btc_to_1_000btc"), + Some("addrs_above_100btc_under_1k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -154,9 +154,9 @@ impl Vecs { states_path, true, )?, - from_1_000btc_to_10_000btc: address_cohort::Vecs::forced_import( + _1k_btc_to_10k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1_000btc_to_10_000btc"), + Some("addrs_above_1k_btc_under_10k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -164,9 +164,9 @@ impl Vecs { states_path, true, )?, - from_10_000btc_to_100_000btc: address_cohort::Vecs::forced_import( + _10k_btc_to_100k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10_000btc_to_100_000btc"), + Some("addrs_above_10k_btc_under_100k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -174,9 +174,9 @@ impl Vecs { states_path, true, )?, - from_100_000btc: address_cohort::Vecs::forced_import( + _100k_btc_or_more: address_cohort::Vecs::forced_import( path, - Some("addresses_from_100_000btc"), + Some("addrs_above_100k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -185,10 +185,10 @@ impl Vecs { true, )?, }, - by_up_to_size: GroupedByUpToSize { + lt_amount: ByLowerThanAmount { _10sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_10sats"), + Some("addrs_under_10sats"), _computation, format, version + VERSION + Version::ZERO, @@ -198,7 +198,7 @@ impl Vecs { )?, _100sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_100sats"), + Some("addrs_under_100sats"), _computation, format, version + VERSION + Version::ZERO, @@ -208,7 +208,7 @@ impl Vecs { )?, _1k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_1k_sats"), + Some("addrs_under_1k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -218,7 +218,7 @@ impl Vecs { )?, _10k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_10k_sats"), + Some("addrs_under_10k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -228,7 +228,7 @@ impl Vecs { )?, _100k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_100k_sats"), + Some("addrs_under_100k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -238,7 +238,7 @@ impl Vecs { )?, _1m_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_1m_sats"), + Some("addrs_under_1m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -248,7 +248,7 @@ impl Vecs { )?, _10m_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_10m_sats"), + Some("addrs_under_10m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -258,7 +258,7 @@ impl Vecs { )?, _1btc: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_1btc"), + Some("addrs_under_1btc"), _computation, format, version + VERSION + Version::ZERO, @@ -268,7 +268,7 @@ impl Vecs { )?, _10btc: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_10btc"), + Some("addrs_under_10btc"), _computation, format, version + VERSION + Version::ZERO, @@ -278,7 +278,7 @@ impl Vecs { )?, _100btc: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_100btc"), + Some("addrs_under_100btc"), _computation, format, version + VERSION + Version::ZERO, @@ -288,7 +288,7 @@ impl Vecs { )?, _1k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_1k_btc"), + Some("addrs_under_1k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -298,7 +298,7 @@ impl Vecs { )?, _10k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_10k_btc"), + Some("addrs_under_10k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -308,7 +308,7 @@ impl Vecs { )?, _100k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_100k_btc"), + Some("addrs_under_100k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -317,10 +317,10 @@ impl Vecs { true, )?, }, - by_from_size: GroupedByFromSize { + ge_amount: ByGreatEqualAmount { _1sat: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1sat"), + Some("addrs_above_1sat"), _computation, format, version + VERSION + Version::ZERO, @@ -330,7 +330,7 @@ impl Vecs { )?, _10sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10sats"), + Some("addrs_above_10sats"), _computation, format, version + VERSION + Version::ZERO, @@ -340,7 +340,7 @@ impl Vecs { )?, _100sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_100sats"), + Some("addrs_above_100sats"), _computation, format, version + VERSION + Version::ZERO, @@ -350,7 +350,7 @@ impl Vecs { )?, _1k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1k_sats"), + Some("addrs_above_1k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -360,7 +360,7 @@ impl Vecs { )?, _10k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10k_sats"), + Some("addrs_above_10k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -370,7 +370,7 @@ impl Vecs { )?, _100k_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_100k_sats"), + Some("addrs_above_100k_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -380,7 +380,7 @@ impl Vecs { )?, _1m_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1m_sats"), + Some("addrs_above_1m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -390,7 +390,7 @@ impl Vecs { )?, _10m_sats: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10m_sats"), + Some("addrs_above_10m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -400,7 +400,7 @@ impl Vecs { )?, _1btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1btc"), + Some("addrs_above_1btc"), _computation, format, version + VERSION + Version::ZERO, @@ -410,7 +410,7 @@ impl Vecs { )?, _10btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10btc"), + Some("addrs_above_10btc"), _computation, format, version + VERSION + Version::ZERO, @@ -420,7 +420,7 @@ impl Vecs { )?, _100btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_100btc"), + Some("addrs_above_100btc"), _computation, format, version + VERSION + Version::ZERO, @@ -430,7 +430,7 @@ impl Vecs { )?, _1k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1k_btc"), + Some("addrs_above_1k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -440,7 +440,7 @@ impl Vecs { )?, _10k_btc: address_cohort::Vecs::forced_import( path, - Some("addresses_from_10k_btc"), + Some("addrs_above_10k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -459,11 +459,11 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let by_size_range = self.0.by_size_range.as_vec(); + let by_size_range = self.0.amount_range.as_vec(); [ self.0 - .by_from_size + .ge_amount .as_mut_vec() .into_iter() .map(|(filter, vecs)| { @@ -478,7 +478,7 @@ impl Vecs { }) .collect::>(), self.0 - .by_up_to_size + .lt_amount .as_mut_vec() .into_iter() .map(|(filter, vecs)| { diff --git a/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount.rs b/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount.rs index c16ccc152..ee387cff6 100644 --- a/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount.rs +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount.rs @@ -1,16 +1,16 @@ -use brk_core::{GroupedByAddressType, Height}; +use brk_core::{ByAddressType, Height}; use brk_vec::VecIterator; use derive_deref::{Deref, DerefMut}; use crate::vecs::stateful::addresstype_to_height_to_addresscount::AddressTypeToHeightToAddressCount; #[derive(Debug, Default, Deref, DerefMut)] -pub struct AddressTypeToAddressCount(GroupedByAddressType); +pub struct AddressTypeToAddressCount(ByAddressType); impl From<(&AddressTypeToHeightToAddressCount, Height)> for AddressTypeToAddressCount { fn from((groups, starting_height): (&AddressTypeToHeightToAddressCount, Height)) -> Self { if let Some(prev_height) = starting_height.decremented() { - Self(GroupedByAddressType { + Self(ByAddressType { p2pk65: groups .p2pk65 .into_iter() diff --git a/crates/brk_computer/src/vecs/stateful/addresstype_to_height_to_addresscount.rs b/crates/brk_computer/src/vecs/stateful/addresstype_to_height_to_addresscount.rs index 9075092e3..98f700654 100644 --- a/crates/brk_computer/src/vecs/stateful/addresstype_to_height_to_addresscount.rs +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_height_to_addresscount.rs @@ -1,4 +1,4 @@ -use brk_core::{GroupedByAddressType, Height, Result, StoredUsize}; +use brk_core::{ByAddressType, Height, Result, StoredUsize}; use brk_exit::Exit; use brk_vec::EagerVec; use derive_deref::{Deref, DerefMut}; @@ -6,12 +6,10 @@ use derive_deref::{Deref, DerefMut}; use crate::vecs::stateful::addresstype_to_addresscount::AddressTypeToAddressCount; #[derive(Debug, Clone, Deref, DerefMut)] -pub struct AddressTypeToHeightToAddressCount(GroupedByAddressType>); +pub struct AddressTypeToHeightToAddressCount(ByAddressType>); -impl From>> - for AddressTypeToHeightToAddressCount -{ - fn from(value: GroupedByAddressType>) -> Self { +impl From>> for AddressTypeToHeightToAddressCount { + fn from(value: ByAddressType>) -> Self { Self(value) } } diff --git a/crates/brk_computer/src/vecs/stateful/addresstype_to_indexes_to_addresscount.rs b/crates/brk_computer/src/vecs/stateful/addresstype_to_indexes_to_addresscount.rs index 1011cb9a7..fd384f0cd 100644 --- a/crates/brk_computer/src/vecs/stateful/addresstype_to_indexes_to_addresscount.rs +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_indexes_to_addresscount.rs @@ -1,4 +1,4 @@ -use brk_core::{GroupedByAddressType, StoredUsize}; +use brk_core::{ByAddressType, StoredUsize}; use brk_exit::Exit; use brk_vec::AnyCollectableVec; use derive_deref::{Deref, DerefMut}; @@ -9,14 +9,12 @@ use crate::vecs::{ }; #[derive(Clone, Deref, DerefMut)] -pub struct AddressTypeToIndexesToAddressCount( - GroupedByAddressType>, -); +pub struct AddressTypeToIndexesToAddressCount(ByAddressType>); -impl From>> +impl From>> for AddressTypeToIndexesToAddressCount { - fn from(value: GroupedByAddressType>) -> Self { + fn from(value: ByAddressType>) -> Self { Self(value) } } diff --git a/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_tree.rs b/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_tree.rs index d136d7596..5a9c19c92 100644 --- a/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_tree.rs +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_tree.rs @@ -3,10 +3,10 @@ use std::{collections::BTreeMap, mem}; use brk_core::TypeIndex; use derive_deref::{Deref, DerefMut}; -use super::GroupedByAddressType; +use super::ByAddressType; #[derive(Debug, Deref, DerefMut)] -pub struct AddressTypeToTypeIndexTree(GroupedByAddressType>); +pub struct AddressTypeToTypeIndexTree(ByAddressType>); impl AddressTypeToTypeIndexTree { pub fn merge(&mut self, mut other: Self) { @@ -29,14 +29,14 @@ impl AddressTypeToTypeIndexTree { } } - pub fn unwrap(self) -> GroupedByAddressType> { + pub fn unwrap(self) -> ByAddressType> { self.0 } } impl Default for AddressTypeToTypeIndexTree { fn default() -> Self { - Self(GroupedByAddressType { + Self(ByAddressType { p2pk65: BTreeMap::default(), p2pk33: BTreeMap::default(), p2pkh: BTreeMap::default(), diff --git a/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_vec.rs b/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_vec.rs index 84c807d74..73a4ee48b 100644 --- a/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_vec.rs +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_typeindex_vec.rs @@ -2,10 +2,10 @@ use std::mem; use derive_deref::{Deref, DerefMut}; -use super::GroupedByAddressType; +use super::ByAddressType; #[derive(Debug, Default, Deref, DerefMut)] -pub struct AddressTypeToVec(GroupedByAddressType>); +pub struct AddressTypeToVec(ByAddressType>); impl AddressTypeToVec { pub fn merge(&mut self, mut other: Self) { diff --git a/crates/brk_computer/src/vecs/stateful/common.rs b/crates/brk_computer/src/vecs/stateful/common.rs index 58154e1b2..36be93b05 100644 --- a/crates/brk_computer/src/vecs/stateful/common.rs +++ b/crates/brk_computer/src/vecs/stateful/common.rs @@ -119,11 +119,11 @@ pub struct Vecs { Option>, pub indexes_to_supply_in_profit_relative_to_circulating_supply: Option>, - pub indexes_to_cumulative_net_realized_profit_and_loss_30d_change: + pub indexes_to_net_realized_profit_and_loss_cumulative_30d_change: Option>, - pub indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap: + pub indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap: Option>, - pub indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap: + pub indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap: Option>, } @@ -929,10 +929,10 @@ impl Vecs { format, StorableVecGeneatorOptions::default().add_sum().add_cumulative(), )?, - indexes_to_cumulative_net_realized_profit_and_loss_30d_change: compute_dollars.then(|| { + indexes_to_net_realized_profit_and_loss_cumulative_30d_change: compute_dollars.then(|| { ComputedVecsFromDateIndex::forced_import( path, - &format!("cumulative_{}", suffix("net_realized_profit_and_loss_30d_change")), + &suffix("net_realized_profit_and_loss_cumulative_30d_change"), true, version + VERSION + Version::new(3), format, @@ -940,10 +940,10 @@ impl Vecs { ) .unwrap() }), - indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap: compute_dollars.then(|| { + indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap: compute_dollars.then(|| { ComputedVecsFromDateIndex::forced_import( path, - &format!("cumulative_{}", suffix("net_realized_profit_and_loss_30d_change_relative_to_realized_cap")), + &suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap"), true, version + VERSION + Version::new(3), format, @@ -951,10 +951,10 @@ impl Vecs { ) .unwrap() }), - indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap: compute_dollars.then(|| { + indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap: compute_dollars.then(|| { ComputedVecsFromDateIndex::forced_import( path, - &format!("cumulative_{}", suffix("net_realized_profit_and_loss_30d_change_relative_to_market_cap")), + &suffix("net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap"), true, version + VERSION + Version::new(3), format, @@ -2530,7 +2530,7 @@ impl Vecs { }, )?; - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change .as_mut() .unwrap() .compute_all( @@ -2552,7 +2552,7 @@ impl Vecs { }, )?; - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap. + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap. as_mut() .unwrap() .compute_all( @@ -2563,14 +2563,14 @@ impl Vecs { |v, _, _, starting_indexes, exit| { v.compute_percentage( starting_indexes.dateindex, - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(), + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(), *dateindex_to_realized_cap.as_ref().unwrap(), exit, ) }, )?; - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap. + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap. as_mut() .unwrap() .compute_all( @@ -2581,7 +2581,7 @@ impl Vecs { |v, _, _, starting_indexes, exit| { v.compute_percentage( starting_indexes.dateindex, - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(), + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change.as_ref().unwrap().dateindex.as_ref().unwrap(), market.indexes_to_marketcap.dateindex.as_ref().unwrap(), exit, ) @@ -2915,11 +2915,11 @@ impl Vecs { .map_or(vec![], |v| v.vecs()), self.indexes_to_coinblocks_destroyed.vecs(), self.indexes_to_coindays_destroyed.vecs(), - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change.as_ref() + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change.as_ref() .map_or(vec![], |v| v.vecs()), - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_realized_cap.as_ref() + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap.as_ref() .map_or(vec![], |v| v.vecs()), - self.indexes_to_cumulative_net_realized_profit_and_loss_30d_change_relative_to_market_cap.as_ref() + self.indexes_to_net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap.as_ref() .map_or(vec![], |v| v.vecs()), ] .into_iter() diff --git a/crates/brk_computer/src/vecs/stateful/mod.rs b/crates/brk_computer/src/vecs/stateful/mod.rs index a3f6aa740..49c1516d3 100644 --- a/crates/brk_computer/src/vecs/stateful/mod.rs +++ b/crates/brk_computer/src/vecs/stateful/mod.rs @@ -1,7 +1,7 @@ use std::{cmp::Ordering, collections::BTreeMap, mem, path::Path, thread}; use brk_core::{ - AddressData, CheckedSub, DateIndex, Dollars, EmptyAddressData, GroupedByAddressType, Height, + AddressData, ByAddressType, CheckedSub, DateIndex, Dollars, EmptyAddressData, Height, InputIndex, OutputIndex, OutputType, Result, Sats, StoredUsize, TypeIndex, Version, }; use brk_exit::Exit; @@ -143,7 +143,7 @@ impl Vecs { StorableVecGeneatorOptions::default().add_last(), )?, addresstype_to_height_to_address_count: AddressTypeToHeightToAddressCount::from( - GroupedByAddressType { + ByAddressType { p2pk65: EagerVec::forced_import( path, "p2pk65_address_count", @@ -195,7 +195,7 @@ impl Vecs { }, ), addresstype_to_height_to_empty_address_count: AddressTypeToHeightToAddressCount::from( - GroupedByAddressType { + ByAddressType { p2pk65: EagerVec::forced_import( path, "p2pk65_empty_address_count", @@ -247,7 +247,7 @@ impl Vecs { }, ), addresstype_to_indexes_to_address_count: AddressTypeToIndexesToAddressCount::from( - GroupedByAddressType { + ByAddressType { p2pk65: ComputedVecsFromHeight::forced_import( path, "p2pk65_address_count", @@ -315,7 +315,7 @@ impl Vecs { }, ), addresstype_to_indexes_to_empty_address_count: AddressTypeToIndexesToAddressCount::from( - GroupedByAddressType { + ByAddressType { p2pk65: ComputedVecsFromHeight::forced_import( path, "p2pk65_empty_address_count", @@ -679,8 +679,8 @@ impl Vecs { let output_count = height_to_output_count_iter.unwrap_get_inner(height); let input_count = height_to_input_count_iter.unwrap_get_inner(height); - let first_addressindexes: GroupedByAddressType = - GroupedByAddressType { + let first_addressindexes: ByAddressType = + ByAddressType { p2a: height_to_first_p2aaddressindex_iter .unwrap_get_inner(height) .into(), @@ -1429,8 +1429,8 @@ impl AddressTypeToVec<(TypeIndex, Sats, Option, >, price: Option, - addresstype_to_address_count: &mut GroupedByAddressType, - addresstype_to_empty_address_count: &mut GroupedByAddressType, + addresstype_to_address_count: &mut ByAddressType, + addresstype_to_empty_address_count: &mut ByAddressType, ) { self.into_typed_vec().into_iter().for_each(|(_type, vec)| { vec.into_iter() @@ -1474,22 +1474,22 @@ impl AddressTypeToVec<(TypeIndex, Sats, Option, >, price: Option, - addresstype_to_address_count: &mut GroupedByAddressType, - addresstype_to_empty_address_count: &mut GroupedByAddressType, + addresstype_to_address_count: &mut ByAddressType, + addresstype_to_empty_address_count: &mut ByAddressType, ) -> Result<()> { self.into_typed_vec() .into_iter() @@ -1556,10 +1556,10 @@ impl // dbg!((prev_amount, amount, will_be_empty)); if will_be_empty - || vecs.by_size_range.get_mut(amount).0.clone() - != vecs.by_size_range.get_mut(prev_amount).0.clone() + || vecs.amount_range.get_mut(amount).0.clone() + != vecs.amount_range.get_mut(prev_amount).0.clone() { - vecs.by_size_range + vecs.amount_range .get_mut(prev_amount) .1 .state @@ -1583,10 +1583,10 @@ impl .unwrap() .insert(type_index, addressdata.into()); } else { - vecs.by_size_range.get_mut(amount).1.state.add(addressdata); + vecs.amount_range.get_mut(amount).1.state.add(addressdata); } } else { - vecs.by_size_range.get_mut(amount).1.state.send( + vecs.amount_range.get_mut(amount).1.state.send( addressdata, value, price, diff --git a/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs b/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs index bb8885136..787c42234 100644 --- a/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs +++ b/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs @@ -1,10 +1,9 @@ use std::{collections::BTreeMap, ops::ControlFlow, path::Path}; use brk_core::{ - CheckedSub, Dollars, GroupFilter, GroupedByDateRange, GroupedByEpoch, GroupedByFromDate, - GroupedByFromSize, GroupedBySizeRange, GroupedBySpendableType, GroupedByTerm, - GroupedByUpToDate, GroupedByUpToSize, HalvingEpoch, Height, Result, Timestamp, UTXOGroups, - Version, + ByAgeRange, ByAmountRange, ByEpoch, ByGreatEqualAmount, ByLowerThanAmount, ByMaxAge, ByMinAge, + BySpendableType, ByTerm, CheckedSub, Dollars, GroupFilter, HalvingEpoch, Height, Result, + Timestamp, UTXOGroups, Version, }; use brk_exit::Exit; use brk_vec::{Computation, Format, StoredIndex}; @@ -44,10 +43,10 @@ impl Vecs { states_path, false, )?, - by_term: GroupedByTerm { + term: ByTerm { short: utxo_cohort::Vecs::forced_import( path, - Some("sth"), + Some("short_term_holders"), _computation, format, version + VERSION + Version::ZERO, @@ -57,7 +56,7 @@ impl Vecs { )?, long: utxo_cohort::Vecs::forced_import( path, - Some("lth"), + Some("long_term_holders"), _computation, format, version + VERSION + Version::ZERO, @@ -66,563 +65,7 @@ impl Vecs { true, )?, }, - by_up_to_date: GroupedByUpToDate { - _1d: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1d"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1w: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1w"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1m: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _2m: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_2m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _3m: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_3m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _4m: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_4m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _5m: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_5m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _6m: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_6m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _2y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_2y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _3y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_3y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _4y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_4y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _5y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_5y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _6y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_6y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _7y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_7y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _8y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_8y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_10y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _15y: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_15y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - }, - by_from_date: GroupedByFromDate { - _1d: utxo_cohort::Vecs::forced_import( - path, - Some("from_1d"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1w: utxo_cohort::Vecs::forced_import( - path, - Some("from_1w"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1m: utxo_cohort::Vecs::forced_import( - path, - Some("from_1m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _2m: utxo_cohort::Vecs::forced_import( - path, - Some("from_2m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _3m: utxo_cohort::Vecs::forced_import( - path, - Some("from_3m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _4m: utxo_cohort::Vecs::forced_import( - path, - Some("from_4m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _5m: utxo_cohort::Vecs::forced_import( - path, - Some("from_5m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _6m: utxo_cohort::Vecs::forced_import( - path, - Some("from_6m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1y: utxo_cohort::Vecs::forced_import( - path, - Some("from_1y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _2y: utxo_cohort::Vecs::forced_import( - path, - Some("from_2y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _3y: utxo_cohort::Vecs::forced_import( - path, - Some("from_3y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _4y: utxo_cohort::Vecs::forced_import( - path, - Some("from_4y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _5y: utxo_cohort::Vecs::forced_import( - path, - Some("from_5y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _6y: utxo_cohort::Vecs::forced_import( - path, - Some("from_6y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _7y: utxo_cohort::Vecs::forced_import( - path, - Some("from_7y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _8y: utxo_cohort::Vecs::forced_import( - path, - Some("from_8y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10y: utxo_cohort::Vecs::forced_import( - path, - Some("from_10y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _15y: utxo_cohort::Vecs::forced_import( - path, - Some("from_15y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - }, - by_date_range: GroupedByDateRange { - start_to_1d: utxo_cohort::Vecs::forced_import( - path, - Some("start_to_1d"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1d_to_1w: utxo_cohort::Vecs::forced_import( - path, - Some("from_1d_to_1w"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1w_to_1m: utxo_cohort::Vecs::forced_import( - path, - Some("from_1w_to_1m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1m_to_2m: utxo_cohort::Vecs::forced_import( - path, - Some("from_1m_to_2m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _2m_to_3m: utxo_cohort::Vecs::forced_import( - path, - Some("from_2m_to_3m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _3m_to_4m: utxo_cohort::Vecs::forced_import( - path, - Some("from_3m_to_4m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _4m_to_5m: utxo_cohort::Vecs::forced_import( - path, - Some("from_4m_to_5m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _5m_to_6m: utxo_cohort::Vecs::forced_import( - path, - Some("from_5m_to_6m"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _6m_to_1y: utxo_cohort::Vecs::forced_import( - path, - Some("from_6m_to_1y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1y_to_2y: utxo_cohort::Vecs::forced_import( - path, - Some("from_1y_to_2y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _2y_to_3y: utxo_cohort::Vecs::forced_import( - path, - Some("from_2y_to_3y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _3y_to_4y: utxo_cohort::Vecs::forced_import( - path, - Some("from_3y_to_4y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _4y_to_5y: utxo_cohort::Vecs::forced_import( - path, - Some("from_4y_to_5y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _5y_to_6y: utxo_cohort::Vecs::forced_import( - path, - Some("from_5y_to_6y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _6y_to_7y: utxo_cohort::Vecs::forced_import( - path, - Some("from_6y_to_7y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _7y_to_8y: utxo_cohort::Vecs::forced_import( - path, - Some("from_7y_to_8y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _8y_to_10y: utxo_cohort::Vecs::forced_import( - path, - Some("from_8y_to_10y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10y_to_15y: utxo_cohort::Vecs::forced_import( - path, - Some("from_10y_to_15y"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _15y_to_end: utxo_cohort::Vecs::forced_import( - path, - Some("from_15y_to_end"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - }, - by_epoch: GroupedByEpoch { + epoch: ByEpoch { _0: utxo_cohort::Vecs::forced_import( path, Some("epoch_0"), @@ -674,423 +117,7 @@ impl Vecs { true, )?, }, - by_size_range: GroupedBySizeRange { - _0sats: utxo_cohort::Vecs::forced_import( - path, - Some("0sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_1sat_to_10sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_1sat_to_10sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_10sats_to_100sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_10sats_to_100sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_100sats_to_1_000sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_100sats_to_1_000sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_1_000sats_to_10_000sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_1_000sats_to_10_000sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_10_000sats_to_100_000sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_10_000sats_to_100_000sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_100_000sats_to_1_000_000sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_100_000sats_to_1_000_000sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_1_000_000sats_to_10_000_000sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_1_000_000sats_to_10_000_000sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_10_000_000sats_to_1btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_10_000_000sats_to_1btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_1btc_to_10btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_1btc_to_10btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_10btc_to_100btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_10btc_to_100btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_100btc_to_1_000btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_100btc_to_1_000btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_1_000btc_to_10_000btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_1_000btc_to_10_000btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_10_000btc_to_100_000btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_10_000btc_to_100_000btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - from_100_000btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_100_000btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - }, - by_up_to_size: GroupedByUpToSize { - _10sats: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_10sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _100sats: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_100sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1k_sats: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1k_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10k_sats: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_10k_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _100k_sats: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_100k_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1m_sats: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1m_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10m_sats: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_10m_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1btc: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10btc: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_10btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _100btc: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_100btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1k_btc: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_1k_btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10k_btc: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_10k_btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _100k_btc: utxo_cohort::Vecs::forced_import( - path, - Some("up_to_100k_btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - }, - by_from_size: GroupedByFromSize { - _1sat: utxo_cohort::Vecs::forced_import( - path, - Some("from_1sat"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_10sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _100sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_100sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1k_sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_1k_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10k_sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_10k_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _100k_sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_100k_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1m_sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_1m_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10m_sats: utxo_cohort::Vecs::forced_import( - path, - Some("from_10m_sats"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_1btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_10btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _100btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_100btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _1k_btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_1k_btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - _10k_btc: utxo_cohort::Vecs::forced_import( - path, - Some("from_10k_btc"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, - }, - by_type: GroupedBySpendableType { + _type: BySpendableType { p2pk65: utxo_cohort::Vecs::forced_import( path, Some("p2pk65"), @@ -1121,16 +148,6 @@ impl Vecs { states_path, true, )?, - p2ms: utxo_cohort::Vecs::forced_import( - path, - Some("p2ms"), - _computation, - format, - version + VERSION + Version::ZERO, - fetched, - states_path, - true, - )?, p2sh: utxo_cohort::Vecs::forced_import( path, Some("p2sh"), @@ -1181,9 +198,19 @@ impl Vecs { states_path, true, )?, + p2ms: utxo_cohort::Vecs::forced_import( + path, + Some("p2ms_outputs"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, empty: utxo_cohort::Vecs::forced_import( path, - Some("empty"), + Some("empty_outputs"), _computation, format, version + VERSION + Version::ZERO, @@ -1193,7 +220,989 @@ impl Vecs { )?, unknown: utxo_cohort::Vecs::forced_import( path, - Some("unknown"), + Some("unknown_outputs"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + }, + max_age: ByMaxAge { + _1w: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_1w_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_1m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _2m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_2m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _3m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_3m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _4m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_4m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _5m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_5m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _6m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_6m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_1y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _2y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_2y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _3y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_3y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _4y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_4y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _5y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_5y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _6y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_6y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _7y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_7y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _8y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_8y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_10y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _12y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_12y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _15y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_15y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + }, + min_age: ByMinAge { + _1d: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1d_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1w: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1w_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _2m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_2m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _3m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_3m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _4m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_4m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _5m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_5m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _6m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_6m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _2y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_2y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _3y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_3y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _4y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_4y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _5y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_5y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _6y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_6y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _7y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_7y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _8y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_8y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_10y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _12y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_12y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + }, + age_range: ByAgeRange { + up_to_1d: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_up_to_1d_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1d_to_1w: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1d_up_to_1w_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1w_to_1m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1w_up_to_1m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m_to_2m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1m_up_to_2m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _2m_to_3m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_2m_up_to_3m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _3m_to_4m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_3m_up_to_4m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _4m_to_5m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_4m_up_to_5m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _5m_to_6m: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_5m_up_to_6m_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _6m_to_1y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_6m_up_to_1y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1y_to_2y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_1y_up_to_2y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _2y_to_3y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_2y_up_to_3y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _3y_to_4y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_3y_up_to_4y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _4y_to_5y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_4y_up_to_5y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _5y_to_6y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_5y_up_to_6y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _6y_to_7y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_6y_up_to_7y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _7y_to_8y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_7y_up_to_8y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _8y_to_10y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_8y_up_to_10y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10y_to_12y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_10y_up_to_12y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _12y_to_15y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_12y_up_to_15y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + from_15y: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_at_least_15y_old"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + }, + amount_range: ByAmountRange { + _0sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_with_0sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1sat_to_10sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1sat_under_10sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10sats_to_100sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10sats_under_100sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100sats_to_1k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_100sats_under_1k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_sats_to_10k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1k_sats_under_10k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_sats_to_100k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10k_sats_under_100k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_sats_to_1m_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_100k_sats_under_1m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m_sats_to_10m_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1m_sats_under_10m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10m_sats_to_1btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10m_sats_under_1btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1btc_to_10btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1btc_under_10btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10btc_to_100btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10btc_under_100btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100btc_to_1k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_100btc_under_1k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_btc_to_10k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1k_btc_under_10k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_btc_to_100k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10k_btc_under_100k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_btc_or_more: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_100k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + }, + lt_amount: ByLowerThanAmount { + _10sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_10sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_100sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_1k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_10k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_100k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_1m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10m_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_10m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_1btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_10btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_100btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_1k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_10k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_under_100k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + }, + ge_amount: ByGreatEqualAmount { + _1sat: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1sat"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_100sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_100k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10m_sats: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_100btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_1k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_btc: utxo_cohort::Vecs::forced_import( + path, + Some("utxos_above_10k_btc"), _computation, format, version + VERSION + Version::ZERO, @@ -1214,7 +1223,7 @@ impl Vecs { let prev_timestamp = chain_state.last().unwrap().timestamp; - self.by_date_range + self.age_range .as_mut_vec() .into_par_iter() .for_each(|(filter, v)| { @@ -1253,10 +1262,10 @@ impl Vecs { ) { let mut time_based_vecs = self .0 - .by_date_range + .age_range .as_mut_vec() .into_iter() - .chain(self.0.by_epoch.as_mut_vec()) + .chain(self.0.epoch.as_mut_vec()) .collect::>(); let last_timestamp = chain_state.last().unwrap().timestamp; @@ -1286,8 +1295,8 @@ impl Vecs { time_based_vecs .iter_mut() .filter(|(filter, _)| match filter { - GroupFilter::From(from) => *from <= days_old, - GroupFilter::To(to) => *to > days_old, + GroupFilter::GreaterOrEqual(from) => *from <= days_old, + GroupFilter::LowerThan(to) => *to > days_old, GroupFilter::Range(range) => range.contains(&days_old), GroupFilter::Epoch(epoch) => *epoch == HalvingEpoch::from(height), _ => unreachable!(), @@ -1305,7 +1314,7 @@ impl Vecs { sent.by_type.spendable.as_typed_vec().into_iter().for_each( |(output_type, supply_state)| { - self.0.by_type.get_mut(output_type).1.state.send( + self.0._type.get_mut(output_type).1.state.send( supply_state, current_price, prev_price, @@ -1320,7 +1329,7 @@ impl Vecs { .as_typed_vec() .into_iter() .for_each(|(group, supply_state)| { - self.0.by_size_range.get_mut(group).1.state.send( + self.0.amount_range.get_mut(group).1.state.send( supply_state, current_price, prev_price, @@ -1336,15 +1345,15 @@ impl Vecs { let supply_state = received.spendable_supply; [ - &mut self.0.by_date_range.start_to_1d.1, - &mut self.0.by_epoch.mut_vec_from_height(height).1, + &mut self.0.age_range.up_to_1d.1, + &mut self.0.epoch.mut_vec_from_height(height).1, ] .into_iter() .for_each(|v| { v.state.receive(&supply_state, price); }); - self.by_type + self._type .as_mut_vec() .into_iter() .for_each(|(filter, vecs)| { @@ -1360,7 +1369,7 @@ impl Vecs { .as_typed_vec() .into_iter() .for_each(|(group, supply_state)| { - self.by_size_range + self.amount_range .get_mut(group) .1 .state @@ -1373,13 +1382,13 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - let by_date_range = self.0.by_date_range.as_vec(); - let by_size_range = self.0.by_size_range.as_vec(); + let by_date_range = self.0.age_range.as_vec(); + let by_size_range = self.0.amount_range.as_vec(); [ - vec![(&mut self.0.all.1, self.0.by_epoch.vecs().to_vec())], + vec![(&mut self.0.all.1, self.0.epoch.vecs().to_vec())], self.0 - .by_from_date + .min_age .as_mut_vec() .into_iter() .map(|(filter, vecs)| { @@ -1394,7 +1403,7 @@ impl Vecs { }) .collect::>(), self.0 - .by_up_to_date + .max_age .as_mut_vec() .into_iter() .map(|(filter, vecs)| { @@ -1409,7 +1418,7 @@ impl Vecs { }) .collect::>(), self.0 - .by_term + .term .as_mut_vec() .into_iter() .map(|(filter, vecs)| { @@ -1424,7 +1433,7 @@ impl Vecs { }) .collect::>(), self.0 - .by_from_size + .ge_amount .as_mut_vec() .into_iter() .map(|(filter, vecs)| { @@ -1439,7 +1448,7 @@ impl Vecs { }) .collect::>(), self.0 - .by_up_to_size + .lt_amount .as_mut_vec() .into_iter() .map(|(filter, vecs)| { diff --git a/crates/brk_core/src/groups/address.rs b/crates/brk_core/src/groups/address.rs index 64f6a8aa6..75a193745 100644 --- a/crates/brk_core/src/groups/address.rs +++ b/crates/brk_core/src/groups/address.rs @@ -1,45 +1,45 @@ -use super::{GroupFilter, GroupedByFromSize, GroupedBySizeRange, GroupedByUpToSize}; +use super::{ByAmountRange, ByGreatEqualAmount, ByLowerThanAmount, GroupFilter}; #[derive(Default, Clone)] pub struct AddressGroups { - pub by_from_size: GroupedByFromSize, - pub by_size_range: GroupedBySizeRange, - pub by_up_to_size: GroupedByUpToSize, + pub ge_amount: ByGreatEqualAmount, + pub amount_range: ByAmountRange, + pub lt_amount: ByLowerThanAmount, } impl AddressGroups { pub fn as_mut_vecs(&mut self) -> Vec<&mut T> { - self.by_from_size + self.ge_amount .as_mut_vec() .into_iter() - .chain(self.by_size_range.as_mut_vec()) - .chain(self.by_up_to_size.as_mut_vec()) + .chain(self.amount_range.as_mut_vec()) + .chain(self.lt_amount.as_mut_vec()) .collect::>() } pub fn as_mut_separate_vecs(&mut self) -> Vec<&mut T> { - self.by_size_range + self.amount_range .as_mut_vec() .into_iter() .collect::>() } pub fn as_mut_overlapping_vecs(&mut self) -> Vec<&mut T> { - self.by_up_to_size + self.lt_amount .as_mut_vec() .into_iter() - .chain(self.by_from_size.as_mut_vec()) + .chain(self.ge_amount.as_mut_vec()) .collect::>() } } impl AddressGroups<(GroupFilter, T)> { pub fn vecs(&self) -> Vec<&T> { - self.by_size_range + self.amount_range .vecs() .into_iter() - .chain(self.by_up_to_size.vecs()) - .chain(self.by_from_size.vecs()) + .chain(self.lt_amount.vecs()) + .chain(self.ge_amount.vecs()) .collect::>() } } @@ -47,9 +47,9 @@ impl AddressGroups<(GroupFilter, T)> { impl From> for AddressGroups<(GroupFilter, T)> { fn from(value: AddressGroups) -> Self { Self { - by_size_range: GroupedBySizeRange::from(value.by_size_range), - by_up_to_size: GroupedByUpToSize::from(value.by_up_to_size), - by_from_size: GroupedByFromSize::from(value.by_from_size), + amount_range: ByAmountRange::from(value.amount_range), + lt_amount: ByLowerThanAmount::from(value.lt_amount), + ge_amount: ByGreatEqualAmount::from(value.ge_amount), } } } diff --git a/crates/brk_core/src/groups/by_address_type.rs b/crates/brk_core/src/groups/by_address_type.rs index e0e77283a..394dca645 100644 --- a/crates/brk_core/src/groups/by_address_type.rs +++ b/crates/brk_core/src/groups/by_address_type.rs @@ -7,7 +7,7 @@ use super::GroupFilter; use crate::OutputType; #[derive(Default, Clone, Debug)] -pub struct GroupedByAddressType { +pub struct ByAddressType { pub p2pk65: T, pub p2pk33: T, pub p2pkh: T, @@ -18,7 +18,7 @@ pub struct GroupedByAddressType { pub p2a: T, } -impl GroupedByAddressType { +impl ByAddressType { pub fn get(&self, address_type: OutputType) -> Option<&T> { match address_type { OutputType::P2PK65 => Some(&self.p2pk65), @@ -103,7 +103,7 @@ impl GroupedByAddressType { } } -impl GroupedByAddressType<(GroupFilter, T)> { +impl ByAddressType<(GroupFilter, T)> { pub fn vecs(&self) -> [&T; 8] { [ &self.p2pk65.1, @@ -118,8 +118,8 @@ impl GroupedByAddressType<(GroupFilter, T)> { } } -impl From> for GroupedByAddressType<(GroupFilter, T)> { - fn from(value: GroupedByAddressType) -> Self { +impl From> for ByAddressType<(GroupFilter, T)> { + fn from(value: ByAddressType) -> Self { Self { p2pk65: (GroupFilter::Type(OutputType::P2PK65), value.p2pk65), p2pk33: (GroupFilter::Type(OutputType::P2PK33), value.p2pk33), @@ -133,7 +133,7 @@ impl From> for GroupedByAddressType<(GroupFilter, T)> } } -impl Add for GroupedByAddressType +impl Add for ByAddressType where T: Add, { @@ -152,7 +152,7 @@ where } } -impl AddAssign for GroupedByAddressType +impl AddAssign for ByAddressType where T: AddAssign, { diff --git a/crates/brk_core/src/groups/by_date_range.rs b/crates/brk_core/src/groups/by_age_range.rs similarity index 74% rename from crates/brk_core/src/groups/by_date_range.rs rename to crates/brk_core/src/groups/by_age_range.rs index 9a01b0ebc..676cffbbb 100644 --- a/crates/brk_core/src/groups/by_date_range.rs +++ b/crates/brk_core/src/groups/by_age_range.rs @@ -1,8 +1,8 @@ use super::GroupFilter; #[derive(Default, Clone)] -pub struct GroupedByDateRange { - pub start_to_1d: T, +pub struct ByAgeRange { + pub up_to_1d: T, pub _1d_to_1w: T, pub _1w_to_1m: T, pub _1m_to_2m: T, @@ -19,14 +19,15 @@ pub struct GroupedByDateRange { pub _6y_to_7y: T, pub _7y_to_8y: T, pub _8y_to_10y: T, - pub _10y_to_15y: T, - pub _15y_to_end: T, + pub _10y_to_12y: T, + pub _12y_to_15y: T, + pub from_15y: T, } -impl From> for GroupedByDateRange<(GroupFilter, T)> { - fn from(value: GroupedByDateRange) -> Self { +impl From> for ByAgeRange<(GroupFilter, T)> { + fn from(value: ByAgeRange) -> Self { Self { - start_to_1d: (GroupFilter::To(1), value.start_to_1d), + up_to_1d: (GroupFilter::LowerThan(1), value.up_to_1d), _1d_to_1w: (GroupFilter::Range(1..7), value._1d_to_1w), _1w_to_1m: (GroupFilter::Range(7..30), value._1w_to_1m), _1m_to_2m: (GroupFilter::Range(30..2 * 30), value._1m_to_2m), @@ -43,16 +44,17 @@ impl From> for GroupedByDateRange<(GroupFilter, T)> { _6y_to_7y: (GroupFilter::Range(6 * 365..7 * 365), value._6y_to_7y), _7y_to_8y: (GroupFilter::Range(7 * 365..8 * 365), value._7y_to_8y), _8y_to_10y: (GroupFilter::Range(8 * 365..10 * 365), value._8y_to_10y), - _10y_to_15y: (GroupFilter::Range(10 * 365..15 * 365), value._10y_to_15y), - _15y_to_end: (GroupFilter::From(15 * 365), value._15y_to_end), + _10y_to_12y: (GroupFilter::Range(10 * 365..12 * 365), value._10y_to_12y), + _12y_to_15y: (GroupFilter::Range(12 * 365..15 * 365), value._12y_to_15y), + from_15y: (GroupFilter::GreaterOrEqual(15 * 365), value.from_15y), } } } -impl GroupedByDateRange { - pub fn as_vec(&mut self) -> [&T; 19] { +impl ByAgeRange { + pub fn as_vec(&mut self) -> [&T; 20] { [ - &self.start_to_1d, + &self.up_to_1d, &self._1d_to_1w, &self._1w_to_1m, &self._1m_to_2m, @@ -69,14 +71,15 @@ impl GroupedByDateRange { &self._6y_to_7y, &self._7y_to_8y, &self._8y_to_10y, - &self._10y_to_15y, - &self._15y_to_end, + &self._10y_to_12y, + &self._12y_to_15y, + &self.from_15y, ] } - pub fn as_mut_vec(&mut self) -> [&mut T; 19] { + pub fn as_mut_vec(&mut self) -> [&mut T; 20] { [ - &mut self.start_to_1d, + &mut self.up_to_1d, &mut self._1d_to_1w, &mut self._1w_to_1m, &mut self._1m_to_2m, @@ -93,16 +96,17 @@ impl GroupedByDateRange { &mut self._6y_to_7y, &mut self._7y_to_8y, &mut self._8y_to_10y, - &mut self._10y_to_15y, - &mut self._15y_to_end, + &mut self._10y_to_12y, + &mut self._12y_to_15y, + &mut self.from_15y, ] } } -impl GroupedByDateRange<(GroupFilter, T)> { - pub fn vecs(&self) -> [&T; 19] { +impl ByAgeRange<(GroupFilter, T)> { + pub fn vecs(&self) -> [&T; 20] { [ - &self.start_to_1d.1, + &self.up_to_1d.1, &self._1d_to_1w.1, &self._1w_to_1m.1, &self._1m_to_2m.1, @@ -119,8 +123,9 @@ impl GroupedByDateRange<(GroupFilter, T)> { &self._6y_to_7y.1, &self._7y_to_8y.1, &self._8y_to_10y.1, - &self._10y_to_15y.1, - &self._15y_to_end.1, + &self._10y_to_12y.1, + &self._12y_to_15y.1, + &self.from_15y.1, ] } } diff --git a/crates/brk_core/src/groups/by_amount_range.rs b/crates/brk_core/src/groups/by_amount_range.rs new file mode 100644 index 000000000..6fdd0594d --- /dev/null +++ b/crates/brk_core/src/groups/by_amount_range.rs @@ -0,0 +1,257 @@ +use std::ops::{Add, AddAssign}; + +use crate::Sats; + +use super::GroupFilter; + +#[derive(Debug, Default, Clone)] +pub struct ByAmountRange { + pub _0sats: T, + pub _1sat_to_10sats: T, + pub _10sats_to_100sats: T, + pub _100sats_to_1k_sats: T, + pub _1k_sats_to_10k_sats: T, + pub _10k_sats_to_100k_sats: T, + pub _100k_sats_to_1m_sats: T, + pub _1m_sats_to_10m_sats: T, + pub _10m_sats_to_1btc: T, + pub _1btc_to_10btc: T, + pub _10btc_to_100btc: T, + pub _100btc_to_1k_btc: T, + pub _1k_btc_to_10k_btc: T, + pub _10k_btc_to_100k_btc: T, + pub _100k_btc_or_more: T, +} + +impl From> for ByAmountRange<(GroupFilter, T)> { + fn from(value: ByAmountRange) -> Self { + #[allow(clippy::inconsistent_digit_grouping)] + Self { + _0sats: (GroupFilter::LowerThan(Sats::_1.into()), value._0sats), + _1sat_to_10sats: ( + GroupFilter::Range(Sats::_1.into()..Sats::_10.into()), + value._1sat_to_10sats, + ), + _10sats_to_100sats: ( + GroupFilter::Range(Sats::_10.into()..Sats::_100.into()), + value._10sats_to_100sats, + ), + _100sats_to_1k_sats: ( + GroupFilter::Range(Sats::_100.into()..Sats::_1K.into()), + value._100sats_to_1k_sats, + ), + _1k_sats_to_10k_sats: ( + GroupFilter::Range(Sats::_1K.into()..Sats::_10K.into()), + value._1k_sats_to_10k_sats, + ), + _10k_sats_to_100k_sats: ( + GroupFilter::Range(Sats::_10K.into()..Sats::_100K.into()), + value._10k_sats_to_100k_sats, + ), + _100k_sats_to_1m_sats: ( + GroupFilter::Range(Sats::_100K.into()..Sats::_1M.into()), + value._100k_sats_to_1m_sats, + ), + _1m_sats_to_10m_sats: ( + GroupFilter::Range(Sats::_1M.into()..Sats::_10M.into()), + value._1m_sats_to_10m_sats, + ), + _10m_sats_to_1btc: ( + GroupFilter::Range(Sats::_10M.into()..Sats::_1BTC.into()), + value._10m_sats_to_1btc, + ), + _1btc_to_10btc: ( + GroupFilter::Range(Sats::_1BTC.into()..Sats::_10BTC.into()), + value._1btc_to_10btc, + ), + _10btc_to_100btc: ( + GroupFilter::Range(Sats::_10BTC.into()..Sats::_100BTC.into()), + value._10btc_to_100btc, + ), + _100btc_to_1k_btc: ( + GroupFilter::Range(Sats::_100BTC.into()..Sats::_1K_BTC.into()), + value._100btc_to_1k_btc, + ), + _1k_btc_to_10k_btc: ( + GroupFilter::Range(Sats::_1K_BTC.into()..Sats::_10K_BTC.into()), + value._1k_btc_to_10k_btc, + ), + _10k_btc_to_100k_btc: ( + GroupFilter::Range(Sats::_10K_BTC.into()..Sats::_100K_BTC.into()), + value._10k_btc_to_100k_btc, + ), + _100k_btc_or_more: ( + GroupFilter::GreaterOrEqual(Sats::_100K_BTC.into()), + value._100k_btc_or_more, + ), + } + } +} + +impl ByAmountRange { + #[allow(clippy::inconsistent_digit_grouping)] + pub fn get_mut(&mut self, value: Sats) -> &mut T { + if value == Sats::ZERO { + &mut self._0sats + } else if value < Sats::_10 { + &mut self._1sat_to_10sats + } else if value < Sats::_100 { + &mut self._10sats_to_100sats + } else if value < Sats::_1K { + &mut self._100sats_to_1k_sats + } else if value < Sats::_10K { + &mut self._1k_sats_to_10k_sats + } else if value < Sats::_100K { + &mut self._10k_sats_to_100k_sats + } else if value < Sats::_1M { + &mut self._100k_sats_to_1m_sats + } else if value < Sats::_10M { + &mut self._1m_sats_to_10m_sats + } else if value < Sats::_1BTC { + &mut self._10m_sats_to_1btc + } else if value < Sats::_10BTC { + &mut self._1btc_to_10btc + } else if value < Sats::_100BTC { + &mut self._10btc_to_100btc + } else if value < Sats::_1K_BTC { + &mut self._100btc_to_1k_btc + } else if value < Sats::_10K_BTC { + &mut self._1k_btc_to_10k_btc + } else if value < Sats::_100K_BTC { + &mut self._10k_btc_to_100k_btc + } else { + &mut self._100k_btc_or_more + } + } + + pub fn as_vec(&self) -> [&T; 15] { + [ + &self._0sats, + &self._1sat_to_10sats, + &self._10sats_to_100sats, + &self._100sats_to_1k_sats, + &self._1k_sats_to_10k_sats, + &self._10k_sats_to_100k_sats, + &self._100k_sats_to_1m_sats, + &self._1m_sats_to_10m_sats, + &self._10m_sats_to_1btc, + &self._1btc_to_10btc, + &self._10btc_to_100btc, + &self._100btc_to_1k_btc, + &self._1k_btc_to_10k_btc, + &self._10k_btc_to_100k_btc, + &self._100k_btc_or_more, + ] + } + + pub fn as_typed_vec(&self) -> [(Sats, &T); 15] { + [ + (Sats::ZERO, &self._0sats), + (Sats::_1, &self._1sat_to_10sats), + (Sats::_10, &self._10sats_to_100sats), + (Sats::_100, &self._100sats_to_1k_sats), + (Sats::_1K, &self._1k_sats_to_10k_sats), + (Sats::_10K, &self._10k_sats_to_100k_sats), + (Sats::_100K, &self._100k_sats_to_1m_sats), + (Sats::_1M, &self._1m_sats_to_10m_sats), + (Sats::_10M, &self._10m_sats_to_1btc), + (Sats::_1BTC, &self._1btc_to_10btc), + (Sats::_10BTC, &self._10btc_to_100btc), + (Sats::_100BTC, &self._100btc_to_1k_btc), + (Sats::_1K_BTC, &self._1k_btc_to_10k_btc), + (Sats::_10K_BTC, &self._10k_btc_to_100k_btc), + (Sats::_100K_BTC, &self._100k_btc_or_more), + ] + } + + pub fn as_mut_vec(&mut self) -> [&mut T; 15] { + [ + &mut self._0sats, + &mut self._1sat_to_10sats, + &mut self._10sats_to_100sats, + &mut self._100sats_to_1k_sats, + &mut self._1k_sats_to_10k_sats, + &mut self._10k_sats_to_100k_sats, + &mut self._100k_sats_to_1m_sats, + &mut self._1m_sats_to_10m_sats, + &mut self._10m_sats_to_1btc, + &mut self._1btc_to_10btc, + &mut self._10btc_to_100btc, + &mut self._100btc_to_1k_btc, + &mut self._1k_btc_to_10k_btc, + &mut self._10k_btc_to_100k_btc, + &mut self._100k_btc_or_more, + ] + } +} + +impl ByAmountRange<(GroupFilter, T)> { + pub fn vecs(&self) -> [&T; 15] { + [ + &self._0sats.1, + &self._1sat_to_10sats.1, + &self._10sats_to_100sats.1, + &self._100sats_to_1k_sats.1, + &self._1k_sats_to_10k_sats.1, + &self._10k_sats_to_100k_sats.1, + &self._100k_sats_to_1m_sats.1, + &self._1m_sats_to_10m_sats.1, + &self._10m_sats_to_1btc.1, + &self._1btc_to_10btc.1, + &self._10btc_to_100btc.1, + &self._100btc_to_1k_btc.1, + &self._1k_btc_to_10k_btc.1, + &self._10k_btc_to_100k_btc.1, + &self._100k_btc_or_more.1, + ] + } +} + +impl Add for ByAmountRange +where + T: Add, +{ + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + Self { + _0sats: self._0sats + rhs._0sats, + _1sat_to_10sats: self._1sat_to_10sats + rhs._1sat_to_10sats, + _10sats_to_100sats: self._10sats_to_100sats + rhs._10sats_to_100sats, + _100sats_to_1k_sats: self._100sats_to_1k_sats + rhs._100sats_to_1k_sats, + _1k_sats_to_10k_sats: self._1k_sats_to_10k_sats + rhs._1k_sats_to_10k_sats, + _10k_sats_to_100k_sats: self._10k_sats_to_100k_sats + rhs._10k_sats_to_100k_sats, + _100k_sats_to_1m_sats: self._100k_sats_to_1m_sats + rhs._100k_sats_to_1m_sats, + _1m_sats_to_10m_sats: self._1m_sats_to_10m_sats + rhs._1m_sats_to_10m_sats, + _10m_sats_to_1btc: self._10m_sats_to_1btc + rhs._10m_sats_to_1btc, + _1btc_to_10btc: self._1btc_to_10btc + rhs._1btc_to_10btc, + _10btc_to_100btc: self._10btc_to_100btc + rhs._10btc_to_100btc, + _100btc_to_1k_btc: self._100btc_to_1k_btc + rhs._100btc_to_1k_btc, + _1k_btc_to_10k_btc: self._1k_btc_to_10k_btc + rhs._1k_btc_to_10k_btc, + _10k_btc_to_100k_btc: self._10k_btc_to_100k_btc + rhs._10k_btc_to_100k_btc, + _100k_btc_or_more: self._100k_btc_or_more + rhs._100k_btc_or_more, + } + } +} + +impl AddAssign for ByAmountRange +where + T: AddAssign, +{ + fn add_assign(&mut self, rhs: Self) { + self._0sats += rhs._0sats; + self._1sat_to_10sats += rhs._1sat_to_10sats; + self._10sats_to_100sats += rhs._10sats_to_100sats; + self._100sats_to_1k_sats += rhs._100sats_to_1k_sats; + self._1k_sats_to_10k_sats += rhs._1k_sats_to_10k_sats; + self._10k_sats_to_100k_sats += rhs._10k_sats_to_100k_sats; + self._100k_sats_to_1m_sats += rhs._100k_sats_to_1m_sats; + self._1m_sats_to_10m_sats += rhs._1m_sats_to_10m_sats; + self._10m_sats_to_1btc += rhs._10m_sats_to_1btc; + self._1btc_to_10btc += rhs._1btc_to_10btc; + self._10btc_to_100btc += rhs._10btc_to_100btc; + self._100btc_to_1k_btc += rhs._100btc_to_1k_btc; + self._1k_btc_to_10k_btc += rhs._1k_btc_to_10k_btc; + self._10k_btc_to_100k_btc += rhs._10k_btc_to_100k_btc; + self._100k_btc_or_more += rhs._100k_btc_or_more; + } +} diff --git a/crates/brk_core/src/groups/by_epoch.rs b/crates/brk_core/src/groups/by_epoch.rs index 13e7de2f2..4132fdace 100644 --- a/crates/brk_core/src/groups/by_epoch.rs +++ b/crates/brk_core/src/groups/by_epoch.rs @@ -3,7 +3,7 @@ use crate::{HalvingEpoch, Height}; use super::GroupFilter; #[derive(Default, Clone)] -pub struct GroupedByEpoch { +pub struct ByEpoch { pub _0: T, pub _1: T, pub _2: T, @@ -11,8 +11,8 @@ pub struct GroupedByEpoch { pub _4: T, } -impl From> for GroupedByEpoch<(GroupFilter, T)> { - fn from(value: GroupedByEpoch) -> Self { +impl From> for ByEpoch<(GroupFilter, T)> { + fn from(value: ByEpoch) -> Self { Self { _0: (GroupFilter::Epoch(HalvingEpoch::new(0)), value._0), _1: (GroupFilter::Epoch(HalvingEpoch::new(1)), value._1), @@ -23,7 +23,7 @@ impl From> for GroupedByEpoch<(GroupFilter, T)> { } } -impl GroupedByEpoch { +impl ByEpoch { pub fn as_mut_vec(&mut self) -> [&mut T; 5] { [ &mut self._0, @@ -52,7 +52,7 @@ impl GroupedByEpoch { } } -impl GroupedByEpoch<(GroupFilter, T)> { +impl ByEpoch<(GroupFilter, T)> { pub fn vecs(&self) -> [&T; 5] { [&self._0.1, &self._1.1, &self._2.1, &self._3.1, &self._4.1] } diff --git a/crates/brk_core/src/groups/by_from_size.rs b/crates/brk_core/src/groups/by_from_size.rs deleted file mode 100644 index 851105100..000000000 --- a/crates/brk_core/src/groups/by_from_size.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::Sats; - -use super::GroupFilter; - -#[derive(Default, Clone)] -pub struct GroupedByFromSize { - pub _1sat: T, - pub _10sats: T, - pub _100sats: T, - pub _1k_sats: T, - pub _10k_sats: T, - pub _100k_sats: T, - pub _1m_sats: T, - pub _10m_sats: T, - pub _1btc: T, - pub _10btc: T, - pub _100btc: T, - pub _1k_btc: T, - pub _10k_btc: T, -} - -impl GroupedByFromSize { - pub fn as_mut_vec(&mut self) -> [&mut T; 13] { - [ - &mut self._1sat, - &mut self._10sats, - &mut self._100sats, - &mut self._1k_sats, - &mut self._10k_sats, - &mut self._100k_sats, - &mut self._1m_sats, - &mut self._10m_sats, - &mut self._1btc, - &mut self._10btc, - &mut self._100btc, - &mut self._1k_btc, - &mut self._10k_btc, - ] - } -} - -impl GroupedByFromSize<(GroupFilter, T)> { - pub fn vecs(&self) -> [&T; 13] { - [ - &self._1sat.1, - &self._10sats.1, - &self._100sats.1, - &self._1k_sats.1, - &self._10k_sats.1, - &self._100k_sats.1, - &self._1m_sats.1, - &self._10m_sats.1, - &self._1btc.1, - &self._10btc.1, - &self._100btc.1, - &self._1k_btc.1, - &self._10k_btc.1, - ] - } -} - -impl From> for GroupedByFromSize<(GroupFilter, T)> { - fn from(value: GroupedByFromSize) -> Self { - Self { - _1sat: (GroupFilter::From(Sats::_1.into()), value._1sat), - _10sats: (GroupFilter::From(Sats::_10.into()), value._10sats), - _100sats: (GroupFilter::From(Sats::_100.into()), value._100sats), - _1k_sats: (GroupFilter::From(Sats::_1K.into()), value._1k_sats), - _10k_sats: (GroupFilter::From(Sats::_10K.into()), value._10k_sats), - _100k_sats: (GroupFilter::From(Sats::_100K.into()), value._100k_sats), - _1m_sats: (GroupFilter::From(Sats::_1M.into()), value._1m_sats), - _10m_sats: (GroupFilter::From(Sats::_10M.into()), value._10m_sats), - _1btc: (GroupFilter::From(Sats::_1BTC.into()), value._1btc), - _10btc: (GroupFilter::From(Sats::_10BTC.into()), value._10btc), - _100btc: (GroupFilter::From(Sats::_100BTC.into()), value._100btc), - _1k_btc: (GroupFilter::From(Sats::_1K_BTC.into()), value._1k_btc), - _10k_btc: (GroupFilter::From(Sats::_10K_BTC.into()), value._10k_btc), - } - } -} diff --git a/crates/brk_core/src/groups/by_ge_amount.rs b/crates/brk_core/src/groups/by_ge_amount.rs new file mode 100644 index 000000000..d358dec17 --- /dev/null +++ b/crates/brk_core/src/groups/by_ge_amount.rs @@ -0,0 +1,110 @@ +use crate::Sats; + +use super::GroupFilter; + +#[derive(Default, Clone)] +pub struct ByGreatEqualAmount { + pub _1sat: T, + pub _10sats: T, + pub _100sats: T, + pub _1k_sats: T, + pub _10k_sats: T, + pub _100k_sats: T, + pub _1m_sats: T, + pub _10m_sats: T, + pub _1btc: T, + pub _10btc: T, + pub _100btc: T, + pub _1k_btc: T, + pub _10k_btc: T, +} + +impl ByGreatEqualAmount { + pub fn as_mut_vec(&mut self) -> [&mut T; 13] { + [ + &mut self._1sat, + &mut self._10sats, + &mut self._100sats, + &mut self._1k_sats, + &mut self._10k_sats, + &mut self._100k_sats, + &mut self._1m_sats, + &mut self._10m_sats, + &mut self._1btc, + &mut self._10btc, + &mut self._100btc, + &mut self._1k_btc, + &mut self._10k_btc, + ] + } +} + +impl ByGreatEqualAmount<(GroupFilter, T)> { + pub fn vecs(&self) -> [&T; 13] { + [ + &self._1sat.1, + &self._10sats.1, + &self._100sats.1, + &self._1k_sats.1, + &self._10k_sats.1, + &self._100k_sats.1, + &self._1m_sats.1, + &self._10m_sats.1, + &self._1btc.1, + &self._10btc.1, + &self._100btc.1, + &self._1k_btc.1, + &self._10k_btc.1, + ] + } +} + +impl From> for ByGreatEqualAmount<(GroupFilter, T)> { + fn from(value: ByGreatEqualAmount) -> Self { + Self { + _1sat: (GroupFilter::GreaterOrEqual(Sats::_1.into()), value._1sat), + _10sats: (GroupFilter::GreaterOrEqual(Sats::_10.into()), value._10sats), + _100sats: ( + GroupFilter::GreaterOrEqual(Sats::_100.into()), + value._100sats, + ), + _1k_sats: ( + GroupFilter::GreaterOrEqual(Sats::_1K.into()), + value._1k_sats, + ), + _10k_sats: ( + GroupFilter::GreaterOrEqual(Sats::_10K.into()), + value._10k_sats, + ), + _100k_sats: ( + GroupFilter::GreaterOrEqual(Sats::_100K.into()), + value._100k_sats, + ), + _1m_sats: ( + GroupFilter::GreaterOrEqual(Sats::_1M.into()), + value._1m_sats, + ), + _10m_sats: ( + GroupFilter::GreaterOrEqual(Sats::_10M.into()), + value._10m_sats, + ), + _1btc: (GroupFilter::GreaterOrEqual(Sats::_1BTC.into()), value._1btc), + _10btc: ( + GroupFilter::GreaterOrEqual(Sats::_10BTC.into()), + value._10btc, + ), + _100btc: ( + GroupFilter::GreaterOrEqual(Sats::_100BTC.into()), + value._100btc, + ), + _1k_btc: ( + GroupFilter::GreaterOrEqual(Sats::_1K_BTC.into()), + value._1k_btc, + ), + _10k_btc: ( + GroupFilter::GreaterOrEqual(Sats::_10K_BTC.into()), + value._10k_btc, + ), + } + } +} diff --git a/crates/brk_core/src/groups/by_lt_amount.rs b/crates/brk_core/src/groups/by_lt_amount.rs new file mode 100644 index 000000000..8fc2191fe --- /dev/null +++ b/crates/brk_core/src/groups/by_lt_amount.rs @@ -0,0 +1,86 @@ +use crate::Sats; + +use super::GroupFilter; + +#[derive(Default, Clone)] +pub struct ByLowerThanAmount { + pub _10sats: T, + pub _100sats: T, + pub _1k_sats: T, + pub _10k_sats: T, + pub _100k_sats: T, + pub _1m_sats: T, + pub _10m_sats: T, + pub _1btc: T, + pub _10btc: T, + pub _100btc: T, + pub _1k_btc: T, + pub _10k_btc: T, + pub _100k_btc: T, +} + +impl ByLowerThanAmount { + pub fn as_mut_vec(&mut self) -> [&mut T; 13] { + [ + &mut self._10sats, + &mut self._100sats, + &mut self._1k_sats, + &mut self._10k_sats, + &mut self._100k_sats, + &mut self._1m_sats, + &mut self._10m_sats, + &mut self._1btc, + &mut self._10btc, + &mut self._100btc, + &mut self._1k_btc, + &mut self._10k_btc, + &mut self._100k_btc, + ] + } +} + +impl ByLowerThanAmount<(GroupFilter, T)> { + pub fn vecs(&self) -> [&T; 13] { + [ + &self._10sats.1, + &self._100sats.1, + &self._1k_sats.1, + &self._10k_sats.1, + &self._100k_sats.1, + &self._1m_sats.1, + &self._10m_sats.1, + &self._1btc.1, + &self._10btc.1, + &self._100btc.1, + &self._1k_btc.1, + &self._10k_btc.1, + &self._100k_btc.1, + ] + } +} + +impl From> for ByLowerThanAmount<(GroupFilter, T)> { + fn from(value: ByLowerThanAmount) -> Self { + Self { + _10sats: (GroupFilter::LowerThan(Sats::_10.into()), value._10sats), + _100sats: (GroupFilter::LowerThan(Sats::_100.into()), value._100sats), + _1k_sats: (GroupFilter::LowerThan(Sats::_1K.into()), value._1k_sats), + _10k_sats: (GroupFilter::LowerThan(Sats::_10K.into()), value._10k_sats), + _100k_sats: (GroupFilter::LowerThan(Sats::_100K.into()), value._100k_sats), + _1m_sats: (GroupFilter::LowerThan(Sats::_1M.into()), value._1m_sats), + _10m_sats: (GroupFilter::LowerThan(Sats::_10M.into()), value._10m_sats), + _1btc: (GroupFilter::LowerThan(Sats::_1BTC.into()), value._1btc), + _10btc: (GroupFilter::LowerThan(Sats::_10BTC.into()), value._10btc), + _100btc: (GroupFilter::LowerThan(Sats::_100BTC.into()), value._100btc), + _1k_btc: (GroupFilter::LowerThan(Sats::_1K_BTC.into()), value._1k_btc), + _10k_btc: ( + GroupFilter::LowerThan(Sats::_10K_BTC.into()), + value._10k_btc, + ), + _100k_btc: ( + GroupFilter::LowerThan(Sats::_100K_BTC.into()), + value._100k_btc, + ), + } + } +} diff --git a/crates/brk_core/src/groups/by_from_date.rs b/crates/brk_core/src/groups/by_max_age.rs similarity index 50% rename from crates/brk_core/src/groups/by_from_date.rs rename to crates/brk_core/src/groups/by_max_age.rs index 6421a1841..225844fc7 100644 --- a/crates/brk_core/src/groups/by_from_date.rs +++ b/crates/brk_core/src/groups/by_max_age.rs @@ -1,8 +1,7 @@ use super::GroupFilter; #[derive(Default, Clone)] -pub struct GroupedByFromDate { - pub _1d: T, +pub struct ByMaxAge { pub _1w: T, pub _1m: T, pub _2m: T, @@ -19,13 +18,13 @@ pub struct GroupedByFromDate { pub _7y: T, pub _8y: T, pub _10y: T, + pub _12y: T, pub _15y: T, } -impl GroupedByFromDate { +impl ByMaxAge { pub fn as_mut_vec(&mut self) -> [&mut T; 18] { [ - &mut self._1d, &mut self._1w, &mut self._1m, &mut self._2m, @@ -42,15 +41,15 @@ impl GroupedByFromDate { &mut self._7y, &mut self._8y, &mut self._10y, + &mut self._12y, &mut self._15y, ] } } -impl GroupedByFromDate<(GroupFilter, T)> { +impl ByMaxAge<(GroupFilter, T)> { pub fn vecs(&self) -> [&T; 18] { [ - &self._1d.1, &self._1w.1, &self._1m.1, &self._2m.1, @@ -67,32 +66,33 @@ impl GroupedByFromDate<(GroupFilter, T)> { &self._7y.1, &self._8y.1, &self._10y.1, + &self._12y.1, &self._15y.1, ] } } -impl From> for GroupedByFromDate<(GroupFilter, T)> { - fn from(value: GroupedByFromDate) -> Self { +impl From> for ByMaxAge<(GroupFilter, T)> { + fn from(value: ByMaxAge) -> Self { Self { - _1d: (GroupFilter::From(1), value._1d), - _1w: (GroupFilter::From(7), value._1w), - _1m: (GroupFilter::From(30), value._1m), - _2m: (GroupFilter::From(2 * 30), value._2m), - _3m: (GroupFilter::From(3 * 30), value._3m), - _4m: (GroupFilter::From(4 * 30), value._4m), - _5m: (GroupFilter::From(5 * 30), value._5m), - _6m: (GroupFilter::From(6 * 30), value._6m), - _1y: (GroupFilter::From(365), value._1y), - _2y: (GroupFilter::From(2 * 365), value._2y), - _3y: (GroupFilter::From(3 * 365), value._3y), - _4y: (GroupFilter::From(4 * 365), value._4y), - _5y: (GroupFilter::From(5 * 365), value._5y), - _6y: (GroupFilter::From(6 * 365), value._6y), - _7y: (GroupFilter::From(7 * 365), value._7y), - _8y: (GroupFilter::From(8 * 365), value._8y), - _10y: (GroupFilter::From(10 * 365), value._10y), - _15y: (GroupFilter::From(15 * 365), value._15y), + _1w: (GroupFilter::LowerThan(7), value._1w), + _1m: (GroupFilter::LowerThan(30), value._1m), + _2m: (GroupFilter::LowerThan(2 * 30), value._2m), + _3m: (GroupFilter::LowerThan(3 * 30), value._3m), + _4m: (GroupFilter::LowerThan(4 * 30), value._4m), + _5m: (GroupFilter::LowerThan(5 * 30), value._5m), + _6m: (GroupFilter::LowerThan(6 * 30), value._6m), + _1y: (GroupFilter::LowerThan(365), value._1y), + _2y: (GroupFilter::LowerThan(2 * 365), value._2y), + _3y: (GroupFilter::LowerThan(3 * 365), value._3y), + _4y: (GroupFilter::LowerThan(4 * 365), value._4y), + _5y: (GroupFilter::LowerThan(5 * 365), value._5y), + _6y: (GroupFilter::LowerThan(6 * 365), value._6y), + _7y: (GroupFilter::LowerThan(7 * 365), value._7y), + _8y: (GroupFilter::LowerThan(8 * 365), value._8y), + _10y: (GroupFilter::LowerThan(10 * 365), value._10y), + _12y: (GroupFilter::LowerThan(12 * 365), value._12y), + _15y: (GroupFilter::LowerThan(15 * 365), value._15y), } } } diff --git a/crates/brk_core/src/groups/by_min_age.rs b/crates/brk_core/src/groups/by_min_age.rs new file mode 100644 index 000000000..6a02fb96f --- /dev/null +++ b/crates/brk_core/src/groups/by_min_age.rs @@ -0,0 +1,98 @@ +use super::GroupFilter; + +#[derive(Default, Clone)] +pub struct ByMinAge { + pub _1d: T, + pub _1w: T, + pub _1m: T, + pub _2m: T, + pub _3m: T, + pub _4m: T, + pub _5m: T, + pub _6m: T, + pub _1y: T, + pub _2y: T, + pub _3y: T, + pub _4y: T, + pub _5y: T, + pub _6y: T, + pub _7y: T, + pub _8y: T, + pub _10y: T, + pub _12y: T, +} + +impl ByMinAge { + pub fn as_mut_vec(&mut self) -> [&mut T; 18] { + [ + &mut self._1d, + &mut self._1w, + &mut self._1m, + &mut self._2m, + &mut self._3m, + &mut self._4m, + &mut self._5m, + &mut self._6m, + &mut self._1y, + &mut self._2y, + &mut self._3y, + &mut self._4y, + &mut self._5y, + &mut self._6y, + &mut self._7y, + &mut self._8y, + &mut self._10y, + &mut self._12y, + ] + } +} + +impl ByMinAge<(GroupFilter, T)> { + pub fn vecs(&self) -> [&T; 18] { + [ + &self._1d.1, + &self._1w.1, + &self._1m.1, + &self._2m.1, + &self._3m.1, + &self._4m.1, + &self._5m.1, + &self._6m.1, + &self._1y.1, + &self._2y.1, + &self._3y.1, + &self._4y.1, + &self._5y.1, + &self._6y.1, + &self._7y.1, + &self._8y.1, + &self._10y.1, + &self._12y.1, + ] + } +} + +impl From> for ByMinAge<(GroupFilter, T)> { + fn from(value: ByMinAge) -> Self { + Self { + _1d: (GroupFilter::GreaterOrEqual(1), value._1d), + _1w: (GroupFilter::GreaterOrEqual(7), value._1w), + _1m: (GroupFilter::GreaterOrEqual(30), value._1m), + _2m: (GroupFilter::GreaterOrEqual(2 * 30), value._2m), + _3m: (GroupFilter::GreaterOrEqual(3 * 30), value._3m), + _4m: (GroupFilter::GreaterOrEqual(4 * 30), value._4m), + _5m: (GroupFilter::GreaterOrEqual(5 * 30), value._5m), + _6m: (GroupFilter::GreaterOrEqual(6 * 30), value._6m), + _1y: (GroupFilter::GreaterOrEqual(365), value._1y), + _2y: (GroupFilter::GreaterOrEqual(2 * 365), value._2y), + _3y: (GroupFilter::GreaterOrEqual(3 * 365), value._3y), + _4y: (GroupFilter::GreaterOrEqual(4 * 365), value._4y), + _5y: (GroupFilter::GreaterOrEqual(5 * 365), value._5y), + _6y: (GroupFilter::GreaterOrEqual(6 * 365), value._6y), + _7y: (GroupFilter::GreaterOrEqual(7 * 365), value._7y), + _8y: (GroupFilter::GreaterOrEqual(8 * 365), value._8y), + _10y: (GroupFilter::GreaterOrEqual(10 * 365), value._10y), + _12y: (GroupFilter::GreaterOrEqual(12 * 365), value._12y), + } + } +} diff --git a/crates/brk_core/src/groups/by_size_range.rs b/crates/brk_core/src/groups/by_size_range.rs deleted file mode 100644 index 9c7668376..000000000 --- a/crates/brk_core/src/groups/by_size_range.rs +++ /dev/null @@ -1,256 +0,0 @@ -use std::ops::{Add, AddAssign}; - -use crate::Sats; - -use super::GroupFilter; - -#[derive(Debug, Default, Clone)] -pub struct GroupedBySizeRange { - pub _0sats: T, - pub from_1sat_to_10sats: T, - pub from_10sats_to_100sats: T, - pub from_100sats_to_1_000sats: T, - pub from_1_000sats_to_10_000sats: T, - pub from_10_000sats_to_100_000sats: T, - pub from_100_000sats_to_1_000_000sats: T, - pub from_1_000_000sats_to_10_000_000sats: T, - pub from_10_000_000sats_to_1btc: T, - pub from_1btc_to_10btc: T, - pub from_10btc_to_100btc: T, - pub from_100btc_to_1_000btc: T, - pub from_1_000btc_to_10_000btc: T, - pub from_10_000btc_to_100_000btc: T, - pub from_100_000btc: T, -} - -impl From> for GroupedBySizeRange<(GroupFilter, T)> { - fn from(value: GroupedBySizeRange) -> Self { - #[allow(clippy::inconsistent_digit_grouping)] - Self { - _0sats: (GroupFilter::To(1), value._0sats), - from_1sat_to_10sats: (GroupFilter::Range(1..10), value.from_1sat_to_10sats), - from_10sats_to_100sats: (GroupFilter::Range(10..100), value.from_10sats_to_100sats), - from_100sats_to_1_000sats: ( - GroupFilter::Range(100..1_000), - value.from_100sats_to_1_000sats, - ), - from_1_000sats_to_10_000sats: ( - GroupFilter::Range(1_000..10_000), - value.from_1_000sats_to_10_000sats, - ), - from_10_000sats_to_100_000sats: ( - GroupFilter::Range(10_000..100_000), - value.from_10_000sats_to_100_000sats, - ), - from_100_000sats_to_1_000_000sats: ( - GroupFilter::Range(100_000..1_000_000), - value.from_100_000sats_to_1_000_000sats, - ), - from_1_000_000sats_to_10_000_000sats: ( - GroupFilter::Range(1_000_000..10_000_000), - value.from_1_000_000sats_to_10_000_000sats, - ), - from_10_000_000sats_to_1btc: ( - GroupFilter::Range(10_000_000..1_00_000_000), - value.from_10_000_000sats_to_1btc, - ), - from_1btc_to_10btc: ( - GroupFilter::Range(1_00_000_000..10_00_000_000), - value.from_1btc_to_10btc, - ), - from_10btc_to_100btc: ( - GroupFilter::Range(10_00_000_000..100_00_000_000), - value.from_10btc_to_100btc, - ), - from_100btc_to_1_000btc: ( - GroupFilter::Range(100_00_000_000..1_000_00_000_000), - value.from_100btc_to_1_000btc, - ), - from_1_000btc_to_10_000btc: ( - GroupFilter::Range(1_000_00_000_000..10_000_00_000_000), - value.from_1_000btc_to_10_000btc, - ), - from_10_000btc_to_100_000btc: ( - GroupFilter::Range(10_000_00_000_000..100_000_00_000_000), - value.from_10_000btc_to_100_000btc, - ), - from_100_000btc: (GroupFilter::From(100_000_00_000_000), value.from_100_000btc), - } - } -} - -impl GroupedBySizeRange { - #[allow(clippy::inconsistent_digit_grouping)] - pub fn get_mut(&mut self, value: Sats) -> &mut T { - if value == Sats::ZERO { - &mut self._0sats - } else if value < Sats::_10 { - &mut self.from_1sat_to_10sats - } else if value < Sats::_100 { - &mut self.from_10sats_to_100sats - } else if value < Sats::_1K { - &mut self.from_100sats_to_1_000sats - } else if value < Sats::_10K { - &mut self.from_1_000sats_to_10_000sats - } else if value < Sats::_100K { - &mut self.from_10_000sats_to_100_000sats - } else if value < Sats::_1M { - &mut self.from_100_000sats_to_1_000_000sats - } else if value < Sats::_10M { - &mut self.from_1_000_000sats_to_10_000_000sats - } else if value < Sats::_1BTC { - &mut self.from_10_000_000sats_to_1btc - } else if value < Sats::_10BTC { - &mut self.from_1btc_to_10btc - } else if value < Sats::_100BTC { - &mut self.from_10btc_to_100btc - } else if value < Sats::_1K_BTC { - &mut self.from_100btc_to_1_000btc - } else if value < Sats::_10K_BTC { - &mut self.from_1_000btc_to_10_000btc - } else if value < Sats::_100K_BTC { - &mut self.from_10_000btc_to_100_000btc - } else { - &mut self.from_100_000btc - } - } - - pub fn as_vec(&self) -> [&T; 15] { - [ - &self._0sats, - &self.from_1sat_to_10sats, - &self.from_10sats_to_100sats, - &self.from_100sats_to_1_000sats, - &self.from_1_000sats_to_10_000sats, - &self.from_10_000sats_to_100_000sats, - &self.from_100_000sats_to_1_000_000sats, - &self.from_1_000_000sats_to_10_000_000sats, - &self.from_10_000_000sats_to_1btc, - &self.from_1btc_to_10btc, - &self.from_10btc_to_100btc, - &self.from_100btc_to_1_000btc, - &self.from_1_000btc_to_10_000btc, - &self.from_10_000btc_to_100_000btc, - &self.from_100_000btc, - ] - } - - pub fn as_typed_vec(&self) -> [(Sats, &T); 15] { - [ - (Sats::ZERO, &self._0sats), - (Sats::_1, &self.from_1sat_to_10sats), - (Sats::_10, &self.from_10sats_to_100sats), - (Sats::_100, &self.from_100sats_to_1_000sats), - (Sats::_1K, &self.from_1_000sats_to_10_000sats), - (Sats::_10K, &self.from_10_000sats_to_100_000sats), - (Sats::_100K, &self.from_100_000sats_to_1_000_000sats), - (Sats::_1M, &self.from_1_000_000sats_to_10_000_000sats), - (Sats::_10M, &self.from_10_000_000sats_to_1btc), - (Sats::_1BTC, &self.from_1btc_to_10btc), - (Sats::_10BTC, &self.from_10btc_to_100btc), - (Sats::_100BTC, &self.from_100btc_to_1_000btc), - (Sats::_1K_BTC, &self.from_1_000btc_to_10_000btc), - (Sats::_10K_BTC, &self.from_10_000btc_to_100_000btc), - (Sats::_100K_BTC, &self.from_100_000btc), - ] - } - - pub fn as_mut_vec(&mut self) -> [&mut T; 15] { - [ - &mut self._0sats, - &mut self.from_1sat_to_10sats, - &mut self.from_10sats_to_100sats, - &mut self.from_100sats_to_1_000sats, - &mut self.from_1_000sats_to_10_000sats, - &mut self.from_10_000sats_to_100_000sats, - &mut self.from_100_000sats_to_1_000_000sats, - &mut self.from_1_000_000sats_to_10_000_000sats, - &mut self.from_10_000_000sats_to_1btc, - &mut self.from_1btc_to_10btc, - &mut self.from_10btc_to_100btc, - &mut self.from_100btc_to_1_000btc, - &mut self.from_1_000btc_to_10_000btc, - &mut self.from_10_000btc_to_100_000btc, - &mut self.from_100_000btc, - ] - } -} - -impl GroupedBySizeRange<(GroupFilter, T)> { - pub fn vecs(&self) -> [&T; 15] { - [ - &self._0sats.1, - &self.from_1sat_to_10sats.1, - &self.from_10sats_to_100sats.1, - &self.from_100sats_to_1_000sats.1, - &self.from_1_000sats_to_10_000sats.1, - &self.from_10_000sats_to_100_000sats.1, - &self.from_100_000sats_to_1_000_000sats.1, - &self.from_1_000_000sats_to_10_000_000sats.1, - &self.from_10_000_000sats_to_1btc.1, - &self.from_1btc_to_10btc.1, - &self.from_10btc_to_100btc.1, - &self.from_100btc_to_1_000btc.1, - &self.from_1_000btc_to_10_000btc.1, - &self.from_10_000btc_to_100_000btc.1, - &self.from_100_000btc.1, - ] - } -} - -impl Add for GroupedBySizeRange -where - T: Add, -{ - type Output = Self; - fn add(self, rhs: Self) -> Self::Output { - Self { - _0sats: self._0sats + rhs._0sats, - from_1sat_to_10sats: self.from_1sat_to_10sats + rhs.from_1sat_to_10sats, - from_10sats_to_100sats: self.from_10sats_to_100sats + rhs.from_10sats_to_100sats, - from_100sats_to_1_000sats: self.from_100sats_to_1_000sats - + rhs.from_100sats_to_1_000sats, - from_1_000sats_to_10_000sats: self.from_1_000sats_to_10_000sats - + rhs.from_1_000sats_to_10_000sats, - from_10_000sats_to_100_000sats: self.from_10_000sats_to_100_000sats - + rhs.from_10_000sats_to_100_000sats, - from_100_000sats_to_1_000_000sats: self.from_100_000sats_to_1_000_000sats - + rhs.from_100_000sats_to_1_000_000sats, - from_1_000_000sats_to_10_000_000sats: self.from_1_000_000sats_to_10_000_000sats - + rhs.from_1_000_000sats_to_10_000_000sats, - from_10_000_000sats_to_1btc: self.from_10_000_000sats_to_1btc - + rhs.from_10_000_000sats_to_1btc, - from_1btc_to_10btc: self.from_1btc_to_10btc + rhs.from_1btc_to_10btc, - from_10btc_to_100btc: self.from_10btc_to_100btc + rhs.from_10btc_to_100btc, - from_100btc_to_1_000btc: self.from_100btc_to_1_000btc + rhs.from_100btc_to_1_000btc, - from_1_000btc_to_10_000btc: self.from_1_000btc_to_10_000btc - + rhs.from_1_000btc_to_10_000btc, - from_10_000btc_to_100_000btc: self.from_10_000btc_to_100_000btc - + rhs.from_10_000btc_to_100_000btc, - from_100_000btc: self.from_100_000btc + rhs.from_100_000btc, - } - } -} - -impl AddAssign for GroupedBySizeRange -where - T: AddAssign, -{ - fn add_assign(&mut self, rhs: Self) { - self._0sats += rhs._0sats; - self.from_1sat_to_10sats += rhs.from_1sat_to_10sats; - self.from_10sats_to_100sats += rhs.from_10sats_to_100sats; - self.from_100sats_to_1_000sats += rhs.from_100sats_to_1_000sats; - self.from_1_000sats_to_10_000sats += rhs.from_1_000sats_to_10_000sats; - self.from_10_000sats_to_100_000sats += rhs.from_10_000sats_to_100_000sats; - self.from_100_000sats_to_1_000_000sats += rhs.from_100_000sats_to_1_000_000sats; - self.from_1_000_000sats_to_10_000_000sats += rhs.from_1_000_000sats_to_10_000_000sats; - self.from_10_000_000sats_to_1btc += rhs.from_10_000_000sats_to_1btc; - self.from_1btc_to_10btc += rhs.from_1btc_to_10btc; - self.from_10btc_to_100btc += rhs.from_10btc_to_100btc; - self.from_100btc_to_1_000btc += rhs.from_100btc_to_1_000btc; - self.from_1_000btc_to_10_000btc += rhs.from_1_000btc_to_10_000btc; - self.from_10_000btc_to_100_000btc += rhs.from_10_000btc_to_100_000btc; - self.from_100_000btc += rhs.from_100_000btc; - } -} diff --git a/crates/brk_core/src/groups/by_spendable_type.rs b/crates/brk_core/src/groups/by_spendable_type.rs index a616229f2..c97042b19 100644 --- a/crates/brk_core/src/groups/by_spendable_type.rs +++ b/crates/brk_core/src/groups/by_spendable_type.rs @@ -5,7 +5,7 @@ use crate::OutputType; use super::GroupFilter; #[derive(Default, Clone, Debug)] -pub struct GroupedBySpendableType { +pub struct BySpendableType { pub p2pk65: T, pub p2pk33: T, pub p2pkh: T, @@ -19,7 +19,7 @@ pub struct GroupedBySpendableType { pub empty: T, } -impl GroupedBySpendableType { +impl BySpendableType { pub fn get_mut(&mut self, output_type: OutputType) -> &mut T { match output_type { OutputType::P2PK65 => &mut self.p2pk65, @@ -70,7 +70,7 @@ impl GroupedBySpendableType { } } -impl GroupedBySpendableType<(GroupFilter, T)> { +impl BySpendableType<(GroupFilter, T)> { pub fn vecs(&self) -> [&T; 11] { [ &self.p2pk65.1, @@ -88,8 +88,8 @@ impl GroupedBySpendableType<(GroupFilter, T)> { } } -impl From> for GroupedBySpendableType<(GroupFilter, T)> { - fn from(value: GroupedBySpendableType) -> Self { +impl From> for BySpendableType<(GroupFilter, T)> { + fn from(value: BySpendableType) -> Self { Self { p2pk65: (GroupFilter::Type(OutputType::P2PK65), value.p2pk65), p2pk33: (GroupFilter::Type(OutputType::P2PK33), value.p2pk33), @@ -106,7 +106,7 @@ impl From> for GroupedBySpendableType<(GroupFilter, } } -impl Add for GroupedBySpendableType +impl Add for BySpendableType where T: Add, { @@ -128,7 +128,7 @@ where } } -impl AddAssign for GroupedBySpendableType +impl AddAssign for BySpendableType where T: AddAssign, { diff --git a/crates/brk_core/src/groups/by_term.rs b/crates/brk_core/src/groups/by_term.rs index c66e41a3a..9e3978f0b 100644 --- a/crates/brk_core/src/groups/by_term.rs +++ b/crates/brk_core/src/groups/by_term.rs @@ -1,28 +1,28 @@ use super::GroupFilter; #[derive(Default, Clone)] -pub struct GroupedByTerm { +pub struct ByTerm { pub short: T, pub long: T, } -impl GroupedByTerm { +impl ByTerm { pub fn as_mut_vec(&mut self) -> [&mut T; 2] { [&mut self.short, &mut self.long] } } -impl GroupedByTerm<(GroupFilter, T)> { +impl ByTerm<(GroupFilter, T)> { pub fn vecs(&self) -> [&T; 2] { [&self.short.1, &self.long.1] } } -impl From> for GroupedByTerm<(GroupFilter, T)> { - fn from(value: GroupedByTerm) -> Self { +impl From> for ByTerm<(GroupFilter, T)> { + fn from(value: ByTerm) -> Self { Self { - short: (GroupFilter::To(5 * 30), value.short), - long: (GroupFilter::From(5 * 30), value.long), + short: (GroupFilter::LowerThan(5 * 30), value.short), + long: (GroupFilter::GreaterOrEqual(5 * 30), value.long), } } } diff --git a/crates/brk_core/src/groups/by_type.rs b/crates/brk_core/src/groups/by_type.rs index daa80dcd6..dd07592d6 100644 --- a/crates/brk_core/src/groups/by_type.rs +++ b/crates/brk_core/src/groups/by_type.rs @@ -2,12 +2,12 @@ use std::ops::{Add, AddAssign}; use crate::OutputType; -use super::{GroupedBySpendableType, GroupedByUnspendableType}; +use super::{BySpendableType, ByUnspendableType}; #[derive(Default, Clone, Debug)] pub struct GroupedByType { - pub spendable: GroupedBySpendableType, - pub unspendable: GroupedByUnspendableType, + pub spendable: BySpendableType, + pub unspendable: ByUnspendableType, } impl GroupedByType { diff --git a/crates/brk_core/src/groups/by_unspendable_type.rs b/crates/brk_core/src/groups/by_unspendable_type.rs index 982c30dd6..2489a7e7f 100644 --- a/crates/brk_core/src/groups/by_unspendable_type.rs +++ b/crates/brk_core/src/groups/by_unspendable_type.rs @@ -1,17 +1,17 @@ use std::ops::{Add, AddAssign}; #[derive(Default, Clone, Debug)] -pub struct GroupedByUnspendableType { +pub struct ByUnspendableType { pub opreturn: T, } -impl GroupedByUnspendableType { +impl ByUnspendableType { pub fn as_vec(&self) -> [&T; 1] { [&self.opreturn] } } -impl Add for GroupedByUnspendableType +impl Add for ByUnspendableType where T: Add, { @@ -23,7 +23,7 @@ where } } -impl AddAssign for GroupedByUnspendableType +impl AddAssign for ByUnspendableType where T: AddAssign, { diff --git a/crates/brk_core/src/groups/by_up_to_date.rs b/crates/brk_core/src/groups/by_up_to_date.rs deleted file mode 100644 index aa09f6f67..000000000 --- a/crates/brk_core/src/groups/by_up_to_date.rs +++ /dev/null @@ -1,98 +0,0 @@ -use super::GroupFilter; - -#[derive(Default, Clone)] -pub struct GroupedByUpToDate { - pub _1d: T, - pub _1w: T, - pub _1m: T, - pub _2m: T, - pub _3m: T, - pub _4m: T, - pub _5m: T, - pub _6m: T, - pub _1y: T, - pub _2y: T, - pub _3y: T, - pub _4y: T, - pub _5y: T, - pub _6y: T, - pub _7y: T, - pub _8y: T, - pub _10y: T, - pub _15y: T, -} - -impl GroupedByUpToDate { - pub fn as_mut_vec(&mut self) -> [&mut T; 18] { - [ - &mut self._1d, - &mut self._1w, - &mut self._1m, - &mut self._2m, - &mut self._3m, - &mut self._4m, - &mut self._5m, - &mut self._6m, - &mut self._1y, - &mut self._2y, - &mut self._3y, - &mut self._4y, - &mut self._5y, - &mut self._6y, - &mut self._7y, - &mut self._8y, - &mut self._10y, - &mut self._15y, - ] - } -} - -impl GroupedByUpToDate<(GroupFilter, T)> { - pub fn vecs(&self) -> [&T; 18] { - [ - &self._1d.1, - &self._1w.1, - &self._1m.1, - &self._2m.1, - &self._3m.1, - &self._4m.1, - &self._5m.1, - &self._6m.1, - &self._1y.1, - &self._2y.1, - &self._3y.1, - &self._4y.1, - &self._5y.1, - &self._6y.1, - &self._7y.1, - &self._8y.1, - &self._10y.1, - &self._15y.1, - ] - } -} - -impl From> for GroupedByUpToDate<(GroupFilter, T)> { - fn from(value: GroupedByUpToDate) -> Self { - Self { - _1d: (GroupFilter::To(1), value._1d), - _1w: (GroupFilter::To(7), value._1w), - _1m: (GroupFilter::To(30), value._1m), - _2m: (GroupFilter::To(2 * 30), value._2m), - _3m: (GroupFilter::To(3 * 30), value._3m), - _4m: (GroupFilter::To(4 * 30), value._4m), - _5m: (GroupFilter::To(5 * 30), value._5m), - _6m: (GroupFilter::To(6 * 30), value._6m), - _1y: (GroupFilter::To(365), value._1y), - _2y: (GroupFilter::To(2 * 365), value._2y), - _3y: (GroupFilter::To(3 * 365), value._3y), - _4y: (GroupFilter::To(4 * 365), value._4y), - _5y: (GroupFilter::To(5 * 365), value._5y), - _6y: (GroupFilter::To(6 * 365), value._6y), - _7y: (GroupFilter::To(7 * 365), value._7y), - _8y: (GroupFilter::To(8 * 365), value._8y), - _10y: (GroupFilter::To(10 * 365), value._10y), - _15y: (GroupFilter::To(15 * 365), value._15y), - } - } -} diff --git a/crates/brk_core/src/groups/by_up_to_size.rs b/crates/brk_core/src/groups/by_up_to_size.rs deleted file mode 100644 index feb977085..000000000 --- a/crates/brk_core/src/groups/by_up_to_size.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::Sats; - -use super::GroupFilter; - -#[derive(Default, Clone)] -pub struct GroupedByUpToSize { - pub _10sats: T, - pub _100sats: T, - pub _1k_sats: T, - pub _10k_sats: T, - pub _100k_sats: T, - pub _1m_sats: T, - pub _10m_sats: T, - pub _1btc: T, - pub _10btc: T, - pub _100btc: T, - pub _1k_btc: T, - pub _10k_btc: T, - pub _100k_btc: T, -} - -impl GroupedByUpToSize { - pub fn as_mut_vec(&mut self) -> [&mut T; 13] { - [ - &mut self._10sats, - &mut self._100sats, - &mut self._1k_sats, - &mut self._10k_sats, - &mut self._100k_sats, - &mut self._1m_sats, - &mut self._10m_sats, - &mut self._1btc, - &mut self._10btc, - &mut self._100btc, - &mut self._1k_btc, - &mut self._10k_btc, - &mut self._100k_btc, - ] - } -} - -impl GroupedByUpToSize<(GroupFilter, T)> { - pub fn vecs(&self) -> [&T; 13] { - [ - &self._10sats.1, - &self._100sats.1, - &self._1k_sats.1, - &self._10k_sats.1, - &self._100k_sats.1, - &self._1m_sats.1, - &self._10m_sats.1, - &self._1btc.1, - &self._10btc.1, - &self._100btc.1, - &self._1k_btc.1, - &self._10k_btc.1, - &self._100k_btc.1, - ] - } -} - -impl From> for GroupedByUpToSize<(GroupFilter, T)> { - fn from(value: GroupedByUpToSize) -> Self { - Self { - _10sats: (GroupFilter::To(Sats::_10.into()), value._10sats), - _100sats: (GroupFilter::To(Sats::_100.into()), value._100sats), - _1k_sats: (GroupFilter::To(Sats::_1K.into()), value._1k_sats), - _10k_sats: (GroupFilter::To(Sats::_10K.into()), value._10k_sats), - _100k_sats: (GroupFilter::To(Sats::_100K.into()), value._100k_sats), - _1m_sats: (GroupFilter::To(Sats::_1M.into()), value._1m_sats), - _10m_sats: (GroupFilter::To(Sats::_10M.into()), value._10m_sats), - _1btc: (GroupFilter::To(Sats::_1BTC.into()), value._1btc), - _10btc: (GroupFilter::To(Sats::_10BTC.into()), value._10btc), - _100btc: (GroupFilter::To(Sats::_100BTC.into()), value._100btc), - _1k_btc: (GroupFilter::To(Sats::_1K_BTC.into()), value._1k_btc), - _10k_btc: (GroupFilter::To(Sats::_10K_BTC.into()), value._10k_btc), - _100k_btc: (GroupFilter::To(Sats::_100K_BTC.into()), value._100k_btc), - } - } -} diff --git a/crates/brk_core/src/groups/filter.rs b/crates/brk_core/src/groups/filter.rs index 0107d573c..d6a738b4e 100644 --- a/crates/brk_core/src/groups/filter.rs +++ b/crates/brk_core/src/groups/filter.rs @@ -5,9 +5,9 @@ use crate::{HalvingEpoch, OutputType}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum GroupFilter { All, - To(usize), + LowerThan(usize), Range(Range), - From(usize), + GreaterOrEqual(usize), Epoch(HalvingEpoch), Type(OutputType), } @@ -16,8 +16,8 @@ impl GroupFilter { pub fn contains(&self, value: usize) -> bool { match self { GroupFilter::All => true, - GroupFilter::To(to) => *to > value, - GroupFilter::From(from) => *from <= value, + GroupFilter::LowerThan(max) => *max > value, + GroupFilter::GreaterOrEqual(min) => *min <= value, GroupFilter::Range(r) => r.contains(&value), GroupFilter::Epoch(_) => false, GroupFilter::Type(_) => false, @@ -27,19 +27,19 @@ impl GroupFilter { pub fn includes(&self, other: &GroupFilter) -> bool { match self { GroupFilter::All => true, - GroupFilter::To(to) => match other { + GroupFilter::LowerThan(max) => match other { GroupFilter::All => false, - GroupFilter::To(to2) => to >= to2, - GroupFilter::Range(range) => range.end <= *to, - GroupFilter::From(_) => false, + GroupFilter::LowerThan(max2) => max >= max2, + GroupFilter::Range(range) => range.end <= *max, + GroupFilter::GreaterOrEqual(_) => false, GroupFilter::Epoch(_) => false, GroupFilter::Type(_) => false, }, - GroupFilter::From(from) => match other { + GroupFilter::GreaterOrEqual(min) => match other { GroupFilter::All => false, - GroupFilter::To(_) => false, - GroupFilter::Range(range) => range.start >= *from, - GroupFilter::From(from2) => from <= from2, + GroupFilter::LowerThan(_) => false, + GroupFilter::Range(range) => range.start >= *min, + GroupFilter::GreaterOrEqual(min2) => min <= min2, GroupFilter::Epoch(_) => false, GroupFilter::Type(_) => false, }, diff --git a/crates/brk_core/src/groups/mod.rs b/crates/brk_core/src/groups/mod.rs index 55cd604af..8ca92df9f 100644 --- a/crates/brk_core/src/groups/mod.rs +++ b/crates/brk_core/src/groups/mod.rs @@ -1,31 +1,31 @@ mod address; mod by_address_type; -mod by_date_range; +mod by_age_range; +mod by_amount_range; mod by_epoch; -mod by_from_date; -mod by_from_size; -mod by_size_range; +mod by_ge_amount; +mod by_lt_amount; +mod by_max_age; +mod by_min_age; mod by_spendable_type; mod by_term; mod by_type; mod by_unspendable_type; -mod by_up_to_date; -mod by_up_to_size; mod filter; mod utxo; pub use address::*; pub use by_address_type::*; -pub use by_date_range::*; +pub use by_age_range::*; +pub use by_amount_range::*; pub use by_epoch::*; -pub use by_from_date::*; -pub use by_from_size::*; -pub use by_size_range::*; +pub use by_ge_amount::*; +pub use by_lt_amount::*; +pub use by_max_age::*; +pub use by_min_age::*; pub use by_spendable_type::*; pub use by_term::*; pub use by_type::*; pub use by_unspendable_type::*; -pub use by_up_to_date::*; -pub use by_up_to_size::*; pub use filter::*; pub use utxo::*; diff --git a/crates/brk_core/src/groups/utxo.rs b/crates/brk_core/src/groups/utxo.rs index 44cf13caf..05bc77921 100644 --- a/crates/brk_core/src/groups/utxo.rs +++ b/crates/brk_core/src/groups/utxo.rs @@ -1,57 +1,56 @@ use crate::{ - GroupFilter, GroupedByDateRange, GroupedByEpoch, GroupedByFromDate, GroupedByFromSize, - GroupedBySizeRange, GroupedBySpendableType, GroupedByTerm, GroupedByUpToDate, - GroupedByUpToSize, + ByAgeRange, ByAmountRange, ByEpoch, ByGreatEqualAmount, ByLowerThanAmount, ByMaxAge, ByMinAge, + BySpendableType, ByTerm, GroupFilter, }; #[derive(Default, Clone)] pub struct UTXOGroups { pub all: T, - pub by_date_range: GroupedByDateRange, - pub by_epoch: GroupedByEpoch, - pub by_from_date: GroupedByFromDate, - pub by_from_size: GroupedByFromSize, - pub by_size_range: GroupedBySizeRange, - pub by_term: GroupedByTerm, - pub by_type: GroupedBySpendableType, - pub by_up_to_date: GroupedByUpToDate, - pub by_up_to_size: GroupedByUpToSize, + pub age_range: ByAgeRange, + pub epoch: ByEpoch, + pub min_age: ByMinAge, + pub ge_amount: ByGreatEqualAmount, + pub amount_range: ByAmountRange, + pub term: ByTerm, + pub _type: BySpendableType, + pub max_age: ByMaxAge, + pub lt_amount: ByLowerThanAmount, } impl UTXOGroups { pub fn as_mut_vecs(&mut self) -> Vec<&mut T> { [&mut self.all] .into_iter() - .chain(self.by_term.as_mut_vec()) - .chain(self.by_up_to_date.as_mut_vec()) - .chain(self.by_from_date.as_mut_vec()) - .chain(self.by_from_size.as_mut_vec()) - .chain(self.by_date_range.as_mut_vec()) - .chain(self.by_epoch.as_mut_vec()) - .chain(self.by_size_range.as_mut_vec()) - .chain(self.by_up_to_size.as_mut_vec()) - .chain(self.by_type.as_mut_vec()) + .chain(self.term.as_mut_vec()) + .chain(self.max_age.as_mut_vec()) + .chain(self.min_age.as_mut_vec()) + .chain(self.ge_amount.as_mut_vec()) + .chain(self.age_range.as_mut_vec()) + .chain(self.epoch.as_mut_vec()) + .chain(self.amount_range.as_mut_vec()) + .chain(self.lt_amount.as_mut_vec()) + .chain(self._type.as_mut_vec()) .collect::>() } pub fn as_mut_separate_vecs(&mut self) -> Vec<&mut T> { - self.by_date_range + self.age_range .as_mut_vec() .into_iter() - .chain(self.by_epoch.as_mut_vec()) - .chain(self.by_size_range.as_mut_vec()) - .chain(self.by_type.as_mut_vec()) + .chain(self.epoch.as_mut_vec()) + .chain(self.amount_range.as_mut_vec()) + .chain(self._type.as_mut_vec()) .collect::>() } pub fn as_mut_overlapping_vecs(&mut self) -> Vec<&mut T> { [&mut self.all] .into_iter() - .chain(self.by_term.as_mut_vec()) - .chain(self.by_up_to_date.as_mut_vec()) - .chain(self.by_from_date.as_mut_vec()) - .chain(self.by_up_to_size.as_mut_vec()) - .chain(self.by_from_size.as_mut_vec()) + .chain(self.term.as_mut_vec()) + .chain(self.max_age.as_mut_vec()) + .chain(self.min_age.as_mut_vec()) + .chain(self.lt_amount.as_mut_vec()) + .chain(self.ge_amount.as_mut_vec()) .collect::>() } } @@ -60,15 +59,15 @@ impl UTXOGroups<(GroupFilter, T)> { pub fn vecs(&self) -> Vec<&T> { [&self.all.1] .into_iter() - .chain(self.by_term.vecs()) - .chain(self.by_up_to_date.vecs()) - .chain(self.by_from_date.vecs()) - .chain(self.by_date_range.vecs()) - .chain(self.by_epoch.vecs()) - .chain(self.by_size_range.vecs()) - .chain(self.by_type.vecs()) - .chain(self.by_up_to_size.vecs()) - .chain(self.by_from_size.vecs()) + .chain(self.term.vecs()) + .chain(self.max_age.vecs()) + .chain(self.min_age.vecs()) + .chain(self.age_range.vecs()) + .chain(self.epoch.vecs()) + .chain(self.amount_range.vecs()) + .chain(self._type.vecs()) + .chain(self.lt_amount.vecs()) + .chain(self.ge_amount.vecs()) .collect::>() } } @@ -77,15 +76,15 @@ impl From> for UTXOGroups<(GroupFilter, T)> { fn from(value: UTXOGroups) -> Self { Self { all: (GroupFilter::All, value.all), - by_term: GroupedByTerm::from(value.by_term), - by_up_to_date: GroupedByUpToDate::from(value.by_up_to_date), - by_from_date: GroupedByFromDate::from(value.by_from_date), - by_date_range: GroupedByDateRange::from(value.by_date_range), - by_epoch: GroupedByEpoch::from(value.by_epoch), - by_size_range: GroupedBySizeRange::from(value.by_size_range), - by_up_to_size: GroupedByUpToSize::from(value.by_up_to_size), - by_from_size: GroupedByFromSize::from(value.by_from_size), - by_type: GroupedBySpendableType::from(value.by_type), + term: ByTerm::from(value.term), + max_age: ByMaxAge::from(value.max_age), + min_age: ByMinAge::from(value.min_age), + age_range: ByAgeRange::from(value.age_range), + epoch: ByEpoch::from(value.epoch), + amount_range: ByAmountRange::from(value.amount_range), + lt_amount: ByLowerThanAmount::from(value.lt_amount), + ge_amount: ByGreatEqualAmount::from(value.ge_amount), + _type: BySpendableType::from(value._type), } } } diff --git a/crates/brk_indexer/src/stores.rs b/crates/brk_indexer/src/stores.rs index 024bba8f8..8c30699ac 100644 --- a/crates/brk_indexer/src/stores.rs +++ b/crates/brk_indexer/src/stores.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, fs, path::Path, thread}; use brk_core::{ - AddressBytes, AddressBytesHash, BlockHashPrefix, GroupedByAddressType, Height, OutputIndex, + AddressBytes, AddressBytesHash, BlockHashPrefix, ByAddressType, Height, OutputIndex, OutputType, Result, TxIndex, TxidPrefix, TypeIndex, TypeIndexWithOutputindex, Unit, Version, }; use brk_store::{AnyStore, Store}; @@ -21,7 +21,7 @@ pub struct Stores { pub blockhashprefix_to_height: Store, pub txidprefix_to_txindex: Store, pub addresstype_to_typeindex_with_outputindex: - GroupedByAddressType>, + ByAddressType>, } const VERSION: Version = Version::ZERO; @@ -145,7 +145,7 @@ impl Stores { addressbyteshash_to_typeindex: addressbyteshash_to_typeindex.join().unwrap()?, blockhashprefix_to_height: blockhashprefix_to_height.join().unwrap()?, txidprefix_to_txindex: txidprefix_to_txindex.join().unwrap()?, - addresstype_to_typeindex_with_outputindex: GroupedByAddressType { + addresstype_to_typeindex_with_outputindex: ByAddressType { p2pk65: p2pk65addressindex_with_outputindex.join().unwrap()?, p2pk33: p2pk33addressindex_with_outputindex.join().unwrap()?, p2pkh: p2pkhaddressindex_with_outputindex.join().unwrap()?, diff --git a/crates/brk_server/README.md b/crates/brk_server/README.md index 2a0d632d0..9f92959e7 100644 --- a/crates/brk_server/README.md +++ b/crates/brk_server/README.md @@ -49,7 +49,7 @@ Get the count of all existing indexes. Get the count of all existing vec ids. -#### [`GET /api/vecs/variant-count`](https://bitcoinresearchkit.org/api/vecs/variant-count) +#### [`GET /api/vecs/vec-count`](https://bitcoinresearchkit.org/api/vecs/vec-count) Get the count of all existing vecs. \ Equals to the sum of supported Indexes of each vec id. diff --git a/crates/brk_server/src/api/interface/bridge.rs b/crates/brk_server/src/api/interface/bridge.rs index a70c8b747..5f0cd2bce 100644 --- a/crates/brk_server/src/api/interface/bridge.rs +++ b/crates/brk_server/src/api/interface/bridge.rs @@ -61,17 +61,34 @@ export const VERSION = \"v{VERSION}\"; ); contents += " -/** @typedef {ReturnType} VecIdToIndexes -/** @typedef {keyof VecIdToIndexes} VecId */ +/** @typedef {ReturnType} Indexes */ + +export function createIndexes() { + return { "; + contents += &indexes + .iter() + .enumerate() + .map(|(i_of_i, i)| { + let lowered = i.to_string().to_lowercase(); + format!(" {lowered}: /** @satisfies {{{i}}} */ ({i_of_i}),",) + }) + .collect::>() + .join("\n"); + + contents += " };\n}\n"; + contents += " +/** @typedef {ReturnType} VecIdToIndexes +/** @typedef {keyof VecIdToIndexes} VecId */ + /** * @returns {Record} */ -export function createVecIdToIndexes() {\n"; - - contents += " return {\n"; +export function createVecIdToIndexes() { + return { +"; self.id_to_index_to_vec() .iter() diff --git a/websites/default/scripts/main.js b/websites/default/scripts/main.js index 62d984e05..c8638ff71 100644 --- a/websites/default/scripts/main.js +++ b/websites/default/scripts/main.js @@ -857,7 +857,9 @@ function createUtils() { } if ( (!unit || thoroughUnitCheck) && - (id.endsWith("_size") || id.endsWith("_size_sum")) + (id.endsWith("_size") || + id.endsWith("_size_sum") || + id.endsWith("_size_cumulative")) ) { if (unit) throw Error(`Unit "${unit}" already assigned "${id}"`); unit = "mb"; @@ -866,7 +868,8 @@ function createUtils() { (!unit || thoroughUnitCheck) && (id.endsWith("vsize") || id.endsWith("vbytes") || - id.endsWith("_vbytes_sum")) + id.endsWith("_vbytes_sum") || + id.endsWith("_vbytes_cumulative")) ) { if (unit) throw Error(`Unit "${unit}" already assigned "${id}"`); unit = "vB"; @@ -1535,8 +1538,10 @@ function createUtils() { /** * @param {Signals} signals * @param {Utilities} utils + * @param {Env} env + * @param {VecIdToIndexes} vecIdToIndexes */ -function createVecsResources(signals, utils) { +function createVecsResources(signals, utils, env, vecIdToIndexes) { const owner = signals.getOwner(); const defaultFrom = -10_000; @@ -1563,6 +1568,10 @@ function createVecsResources(signals, utils) { * @param {VecId} id */ function createVecResource(index, id) { + if (env.localhost && !(id in vecIdToIndexes)) { + throw Error(`${id} not recognized`); + } + return signals.runWithOwner(owner, () => { /** @typedef {T extends number ? SingleValueData : CandlestickData} Value */ @@ -2140,7 +2149,12 @@ function main() { const webSockets = initWebSockets(signals, utils); - const vecsResources = createVecsResources(signals, utils); + const vecsResources = createVecsResources( + signals, + utils, + env, + vecIdToIndexes, + ); const colors = createColors(dark, elements); diff --git a/websites/default/scripts/options.js b/websites/default/scripts/options.js index a7ddcf1ba..ff2569870 100644 --- a/websites/default/scripts/options.js +++ b/websites/default/scripts/options.js @@ -208,13 +208,13 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { const terms = /** @type {const} */ ([ { - key: "sth", + key: "short_term_holders", name: "short", title: "Short Term Holders", color: colors.yellow, }, { - key: "lth", + key: "long_term_holders", name: "long", title: "Long Term Holders", color: colors.fuchsia, @@ -223,341 +223,359 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { const upToDate = /** @type {const} */ ([ { - key: "up_to_1d", + key: "utxos_up_to_1d_old", name: "1d", - title: "Up to 1 Day", + title: "UTXOs Up to 1 Day old", color: colors.pink, }, { - key: "up_to_1w", + key: "utxos_up_to_1w_old", name: "1w", - title: "Up to 1 Week", + title: "UTXOs Up to 1 Week old", color: colors.red, }, { - key: "up_to_1m", + key: "utxos_up_to_1m_old", name: "1m", - title: "Up to 1 Month", + title: "UTXOs Up to 1 Month old", color: colors.orange, }, { - key: "up_to_2m", + key: "utxos_up_to_2m_old", name: "2m", - title: "Up to 2 Months", + title: "UTXOs Up to 2 Months old", color: colors.amber, }, { - key: "up_to_3m", + key: "utxos_up_to_3m_old", name: "3m", - title: "Up to 3 Months", + title: "UTXOs Up to 3 Months old", color: colors.yellow, }, { - key: "up_to_4m", + key: "utxos_up_to_4m_old", name: "4m", - title: "Up to 4 Months", + title: "UTXOs Up to 4 Months old", color: colors.lime, }, { - key: "up_to_5m", + key: "utxos_up_to_5m_old", name: "5m", - title: "Up to 5 Months", + title: "UTXOs Up to 5 Months old", color: colors.green, }, { - key: "up_to_6m", + key: "utxos_up_to_6m_old", name: "6m", - title: "Up to 6 Months", + title: "UTXOs Up to 6 Months old", color: colors.teal, }, { - key: "up_to_1y", + key: "utxos_up_to_1y_old", name: "1y", - title: "Up to 1 Year", + title: "UTXOs Up to 1 Year old", color: colors.sky, }, { - key: "up_to_2y", + key: "utxos_up_to_2y_old", name: "2y", - title: "Up to 2 Years", + title: "UTXOs Up to 2 Years old", color: colors.indigo, }, { - key: "up_to_3y", + key: "utxos_up_to_3y_old", name: "3y", - title: "Up to 3 Years", + title: "UTXOs Up to 3 Years old", color: colors.violet, }, { - key: "up_to_4y", + key: "utxos_up_to_4y_old", name: "4y", - title: "Up to 4 Years", + title: "UTXOs Up to 4 Years old", color: colors.purple, }, { - key: "up_to_5y", + key: "utxos_up_to_5y_old", name: "5y", - title: "Up to 5 Years", + title: "UTXOs Up to 5 Years old", color: colors.fuchsia, }, { - key: "up_to_6y", + key: "utxos_up_to_6y_old", name: "6y", - title: "Up to 6 Years", + title: "UTXOs Up to 6 Years old", color: colors.pink, }, { - key: "up_to_7y", + key: "utxos_up_to_7y_old", name: "7y", - title: "Up to 7 Years", + title: "UTXOs Up to 7 Years old", color: colors.red, }, { - key: "up_to_8y", + key: "utxos_up_to_8y_old", name: "8y", - title: "Up to 8 Years", + title: "UTXOs Up to 8 Years old", color: colors.orange, }, { - key: "up_to_10y", + key: "utxos_up_to_10y_old", name: "10y", - title: "Up to 10 Years", + title: "UTXOs Up to 10 Years old", color: colors.amber, }, { - key: "up_to_15y", - name: "15y", - title: "Up to 15 Years", + key: "utxos_up_to_12y_old", + name: "12y", + title: "UTXOs Up to 12 Years old", color: colors.yellow, }, + { + key: "utxos_up_to_15y_old", + name: "15y", + title: "UTXOs Up to 15 Years old", + color: colors.lime, + }, ]); const fromDate = /** @type {const} */ ([ { - key: "from_1d", + key: "utxos_at_least_1d_old", name: "1d", - title: "From 1 Day", + title: "UTXOs at least 1 Day old", color: colors.red, }, { - key: "from_1w", + key: "utxos_at_least_1w_old", name: "1w", - title: "From 1 Week", + title: "UTXOs at least 1 Week old", color: colors.orange, }, { - key: "from_1m", + key: "utxos_at_least_1m_old", name: "1m", - title: "From 1 Month", + title: "UTXOs at least 1 Month old", color: colors.yellow, }, { - key: "from_2m", + key: "utxos_at_least_2m_old", name: "2m", - title: "From 2 Months", + title: "UTXOs at least 2 Months old", color: colors.lime, }, { - key: "from_3m", + key: "utxos_at_least_3m_old", name: "3m", - title: "From 3 Months", + title: "UTXOs at least 3 Months old", color: colors.green, }, { - key: "from_4m", + key: "utxos_at_least_4m_old", name: "4m", - title: "From 4 Months", + title: "UTXOs at least 4 Months old", color: colors.teal, }, { - key: "from_5m", + key: "utxos_at_least_5m_old", name: "5m", - title: "From 5 Months", + title: "UTXOs at least 5 Months old", color: colors.cyan, }, { - key: "from_6m", + key: "utxos_at_least_6m_old", name: "6m", - title: "From 6 Months", + title: "UTXOs at least 6 Months old", color: colors.blue, }, { - key: "from_1y", + key: "utxos_at_least_1y_old", name: "1y", - title: "From 1 Year", + title: "UTXOs at least 1 Year old", color: colors.indigo, }, { - key: "from_2y", + key: "utxos_at_least_2y_old", name: "2y", - title: "From 2 Years", + title: "UTXOs at least 2 Years old", color: colors.violet, }, { - key: "from_3y", + key: "utxos_at_least_3y_old", name: "3y", - title: "From 3 Years", + title: "UTXOs at least 3 Years old", color: colors.purple, }, { - key: "from_4y", + key: "utxos_at_least_4y_old", name: "4y", - title: "From 4 Years", + title: "UTXOs at least 4 Years old", color: colors.fuchsia, }, { - key: "from_5y", + key: "utxos_at_least_5y_old", name: "5y", - title: "From 5 Years", + title: "UTXOs at least 5 Years old", color: colors.pink, }, { - key: "from_6y", + key: "utxos_at_least_6y_old", name: "6y", - title: "From 6 Years", + title: "UTXOs at least 6 Years old", color: colors.rose, }, { - key: "from_7y", + key: "utxos_at_least_7y_old", name: "7y", - title: "From 7 Years", + title: "UTXOs at least 7 Years old", color: colors.red, }, { - key: "from_8y", + key: "utxos_at_least_8y_old", name: "8y", - title: "From 8 Years", + title: "UTXOs at least 8 Years old", color: colors.orange, }, { - key: "from_10y", + key: "utxos_at_least_10y_old", name: "10y", - title: "From 10 Years", + title: "UTXOs at least 10 Years old", color: colors.yellow, }, { - key: "from_15y", - name: "15y", - title: "From 15 Years", + key: "utxos_at_least_12y_old", + name: "12y", + title: "UTXOs at least 12 Years old", color: colors.lime, }, + { + key: "utxos_at_least_15y_old", + name: "15y", + title: "UTXOs at least 15 Years old", + color: colors.green, + }, ]); const dateRange = /** @type {const} */ ([ { - key: "start_to_1d", - name: "24h", - title: "Last 24 hours", + key: "utxos_up_to_1d_old", + name: "1d", + title: "UTXOs New Up to 1 Day old", color: colors.pink, }, { - key: "from_1d_to_1w", + key: "utxos_at_least_1d_up_to_1w_old", name: "1d..1w", - title: "From 1 Day ago to 1 Week ago", + title: "UTXOs At least 1 Day ago Up to 1 Week old", color: colors.red, }, { - key: "from_1w_to_1m", + key: "utxos_at_least_1w_up_to_1m_old", name: "1w..1m", - title: "From 1 Week ago to 1 Month ago", + title: "UTXOs At least 1 Week ago Up to 1 Month old", color: colors.orange, }, { - key: "from_1m_to_2m", + key: "utxos_at_least_1m_up_to_2m_old", name: "1m..2m", - title: "From 1 Month ago to 2 Months ago", + title: "UTXOs At least 1 Month ago Up to 2 Months old", color: colors.yellow, }, { - key: "from_2m_to_3m", + key: "utxos_at_least_2m_up_to_3m_old", name: "2m..3m", - title: "From 2 Month ago to 3 Months ago", + title: "UTXOs At least 2 Month ago Up to 3 Months old", color: colors.yellow, }, { - key: "from_3m_to_4m", + key: "utxos_at_least_3m_up_to_4m_old", name: "3m..4m", - title: "From 3 Month ago to 4 Months ago", + title: "UTXOs At least 3 Month ago Up to 4 Months old", color: colors.lime, }, { - key: "from_4m_to_5m", + key: "utxos_at_least_4m_up_to_5m_old", name: "4m..5m", - title: "From 4 Month ago to 5 Months ago", + title: "UTXOs At least 4 Month ago Up to 5 Months old", color: colors.lime, }, { - key: "from_5m_to_6m", + key: "utxos_at_least_5m_up_to_6m_old", name: "5m..6m", - title: "From 5 Month ago to 6 Months ago", + title: "UTXOs At least 5 Month ago Up to 6 Months old", color: colors.lime, }, { - key: "from_6m_to_1y", + key: "utxos_at_least_6m_up_to_1y_old", name: "6m..1y", - title: "From 6 Months ago to 1 Year ago", + title: "UTXOs At least 6 Months ago Up to 1 Year old", color: colors.green, }, { - key: "from_1y_to_2y", + key: "utxos_at_least_1y_up_to_2y_old", name: "1y..2y", - title: "From 1 Year ago to 2 Years ago", + title: "UTXOs At least 1 Year ago Up to 2 Years old", color: colors.cyan, }, { - key: "from_2y_to_3y", + key: "utxos_at_least_2y_up_to_3y_old", name: "2y..3y", - title: "From 2 Years ago to 3 Years ago", + title: "UTXOs At least 2 Years ago Up to 3 Years old", color: colors.blue, }, { - key: "from_3y_to_4y", + key: "utxos_at_least_3y_up_to_4y_old", name: "3y..4y", - title: "From 3 Years ago to 4 Years ago", + title: "UTXOs At least 3 Years ago Up to 4 Years old", color: colors.indigo, }, { - key: "from_4y_to_5y", + key: "utxos_at_least_4y_up_to_5y_old", name: "4y..5y", - title: "From 4 Years ago to 5 Years ago", + title: "UTXOs At least 4 Years ago Up to 5 Years old", color: colors.violet, }, { - key: "from_5y_to_6y", + key: "utxos_at_least_5y_up_to_6y_old", name: "5y..6y", - title: "From 5 Years ago to 6 Years ago", + title: "UTXOs At least 5 Years ago Up to 6 Years old", color: colors.purple, }, { - key: "from_6y_to_7y", + key: "utxos_at_least_6y_up_to_7y_old", name: "6y..7y", - title: "From 6 Years ago to 7 Years ago", + title: "UTXOs At least 6 Years ago Up to 7 Years old", color: colors.purple, }, { - key: "from_7y_to_8y", + key: "utxos_at_least_7y_up_to_8y_old", name: "7y..8y", - title: "From 7 Years ago to 8 Years ago", + title: "UTXOs At least 7 Years ago Up to 8 Years old", color: colors.fuchsia, }, { - key: "from_8y_to_10y", + key: "utxos_at_least_8y_up_to_10y_old", name: "8y..10y", - title: "From 8 Years ago to 10 Years ago", + title: "UTXOs At least 8 Years ago Up to 10 Years old", color: colors.fuchsia, }, { - key: "from_10y_to_15y", - name: "10y..15y", - title: "From 10 Years ago to 15 Years ago", + key: "utxos_at_least_10y_up_to_12y_old", + name: "10y..12y", + title: "UTXOs At least 10 Years ago Up to 12 Years old", color: colors.pink, }, { - key: "from_15y_to_end", - name: "15y+", - title: "From 15 Years ago to genesis (2009_01_03)", + key: "utxos_at_least_12y_up_to_15y_old", + name: "12y..15y", + title: "UTXOs At least 12 Years ago Up to 15 Years old", color: colors.red, }, + { + key: "utxos_at_least_15y_old", + name: "15y+", + title: "UTXOs At least 15 Years old up to genesis", + color: colors.orange, + }, ]); const epoch = /** @type {const} */ ([ @@ -593,261 +611,321 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, ]); - const fromSize = /** @type {const} */ ([ + const aboveAmount = /** @type {const} */ ([ { - key: "from_1sat", + key: "above_1sat", name: ">=1 sat", - title: "From 1 sat", + title: "Above 1 sat", color: colors.orange, }, { - key: "from_10sats", + key: "above_10sats", name: ">=10 sats", - title: "From 10 sats", + title: "Above 10 sats", color: colors.orange, }, { - key: "from_100sats", + key: "above_100sats", name: ">=100 sats", - title: "From 100 sats", + title: "Above 100 sats", color: colors.yellow, }, { - key: "from_1k_sats", + key: "above_1k_sats", name: ">=1K sats", - title: "From 1K sats", + title: "Above 1K sats", color: colors.lime, }, { - key: "from_10k_sats", + key: "above_10k_sats", name: ">=10K sats", - title: "From 10K sats", + title: "Above 10K sats", color: colors.green, }, { - key: "from_100k_sats", + key: "above_100k_sats", name: ">=100K sats", - title: "From 100K sats", + title: "Above 100K sats", color: colors.cyan, }, { - key: "from_1m_sats", + key: "above_1m_sats", name: ">=1M sats", - title: "From 1M sats", + title: "Above 1M sats", color: colors.blue, }, { - key: "from_10m_sats", + key: "above_10m_sats", name: ">=10M sats", - title: "From 10M sats", + title: "Above 10M sats", color: colors.indigo, }, { - key: "from_1btc", + key: "above_1btc", name: ">=1 btc", - title: "From 1 BTC", + title: "Above 1 BTC", color: colors.purple, }, { - key: "from_10btc", + key: "above_10btc", name: ">=10 btc", - title: "From 10 BTC", + title: "Above 10 BTC", color: colors.violet, }, { - key: "from_100btc", + key: "above_100btc", name: ">=100 btc", - title: "From 100 BTC", + title: "Above 100 BTC", color: colors.fuchsia, }, { - key: "from_1k_btc", + key: "above_1k_btc", name: ">=1K btc", - title: "From 1K BTC", + title: "Above 1K BTC", color: colors.pink, }, { - key: "from_10k_btc", + key: "above_10k_btc", name: ">=10K btc", - title: "From 10K BTC", + title: "Above 10K BTC", color: colors.red, }, ]); - const upToSize = /** @type {const} */ ([ + const utxosAboveAmount = aboveAmount.map( + ({ key, name, title, color }) => + /** @type {const} */ ({ + key: `utxos_${key}`, + name, + title: `UTXOs ${title}`, + color, + }), + ); + + const addressesAboveAmount = aboveAmount.map( + ({ key, name, title, color }) => + /** @type {const} */ ({ + key: `addrs_${key}`, + name, + title: `Addresses ${title}`, + color, + }), + ); + + const underAmount = /** @type {const} */ ([ { - key: "up_to_10sats", + key: "under_10sats", name: "<10 sats", - title: "Up to 10 sats", + title: "under 10 sats", color: colors.orange, }, { - key: "up_to_100sats", + key: "under_100sats", name: "<100 sats", - title: "Up to 100 sats", + title: "under 100 sats", color: colors.yellow, }, { - key: "up_to_1k_sats", - name: "<1K sats", - title: "Up to 1K sats", + key: "under_1k_sats", + name: "<1k sats", + title: "under 1k sats", color: colors.lime, }, { - key: "up_to_10k_sats", - name: "<10K sats", - title: "Up to 10K sats", + key: "under_10k_sats", + name: "<10k sats", + title: "under 10k sats", color: colors.green, }, { - key: "up_to_100k_sats", - name: "<100K sats", - title: "Up to 100K sats", + key: "under_100k_sats", + name: "<100k sats", + title: "under 100k sats", color: colors.cyan, }, { - key: "up_to_1m_sats", - name: "<1M sats", - title: "Up to 1M sats", + key: "under_1m_sats", + name: "<1m sats", + title: "under 1m sats", color: colors.blue, }, { - key: "up_to_10m_sats", - name: "<10M sats", - title: "Up to 10M sats", + key: "under_10m_sats", + name: "<10m sats", + title: "under 10m sats", color: colors.indigo, }, { - key: "up_to_1btc", + key: "under_1btc", name: "<1 btc", - title: "up to 1 BTC", + title: "under 1 btc", color: colors.purple, }, { - key: "up_to_10btc", + key: "under_10btc", name: "<10 btc", - title: "Up to 10 BTC", + title: "under 10 btc", color: colors.violet, }, { - key: "up_to_100btc", + key: "under_100btc", name: "<100 btc", - title: "Up to 100 BTC", + title: "under 100 btc", color: colors.fuchsia, }, { - key: "up_to_1k_btc", - name: "<1K btc", - title: "up to 1K BTC", + key: "under_1k_btc", + name: "<1k btc", + title: "under 1k btc", color: colors.pink, }, { - key: "up_to_10k_btc", - name: "<10K btc", - title: "up to 10K BTC", + key: "under_10k_btc", + name: "<10k btc", + title: "under 10k btc", color: colors.red, }, { - key: "up_to_100k_btc", - name: "<100K btc", - title: "up to 100K BTC", + key: "under_100k_btc", + name: "<100k btc", + title: "under 100k btc", color: colors.orange, }, ]); - const sizeRanges = /** @type {const} */ ([ + const utxosUnderAmount = underAmount.map( + ({ key, name, title, color }) => + /** @type {const} */ ({ + key: `utxos_${key}`, + name, + title: `UTXOs ${title}`, + color, + }), + ); + + const addressesUnderAmount = underAmount.map( + ({ key, name, title, color }) => + /** @type {const} */ ({ + key: `addrs_${key}`, + name, + title: `Addresses ${title}`, + color, + }), + ); + + const amountRanges = /** @type {const} */ ([ { - key: "0sats", + key: "with_0sats", name: "0 sats", - title: "0 sats", + title: "valued 0 sats", color: colors.red, }, { - key: "from_1sat_to_10sats", + key: "above_1sat_under_10sats", name: "1 sat..10 sats", - title: "From 1 sat to 10 sats", + title: "Above 1 sat Under 10 sats", color: colors.orange, }, { - key: "from_10sats_to_100sats", + key: "above_10sats_under_100sats", name: "10 sats..100 sats", - title: "From 10 sats to 100 sats", + title: "Above 10 sats Under 100 sats", color: colors.yellow, }, { - key: "from_100sats_to_1_000sats", + key: "above_100sats_under_1k_sats", name: "100 sats..1K sats", - title: "From 100 sats to 1K sats", + title: "Above 100 sats Under 1K sats", color: colors.lime, }, { - key: "from_1_000sats_to_10_000sats", + key: "above_1k_sats_under_10k_sats", name: "1K sats..10K sats", - title: "From 1K sats to 10K sats", + title: "Above 1K sats Under 10K sats", color: colors.green, }, { - key: "from_10_000sats_to_100_000sats", + key: "above_10k_sats_under_100k_sats", name: "10K sats..100K sats", - title: "From 10K sats to 100K sats", + title: "Above 10K sats Under 100K sats", color: colors.cyan, }, { - key: "from_100_000sats_to_1_000_000sats", + key: "above_100k_sats_under_1m_sats", name: "100K sats .. 1M sats", - title: "From 100K sats to 1M sats", + title: "Above 100K sats Under 1M sats", color: colors.blue, }, { - key: "from_1_000_000sats_to_10_000_000sats", + key: "above_1m_sats_under_10m_sats", name: "1M sats..10M sats", - title: "From 1M sats to 10M sats", + title: "Above 1M sats Under 10M sats", color: colors.indigo, }, { - key: "from_10_000_000sats_to_1btc", + key: "above_10m_sats_under_1btc", name: "10M sats..1 btc", - title: "From 10M sats to 1 BTC", + title: "Above 10M sats Under 1 BTC", color: colors.purple, }, { - key: "from_1btc_to_10btc", + key: "above_1btc_under_10btc", name: "1 btc..10 btc", - title: "From 1 BTC to 10 BTC", + title: "Above 1 BTC Under 10 BTC", color: colors.violet, }, { - key: "from_10btc_to_100btc", + key: "above_10btc_under_100btc", name: "10 btc..100 btc", - title: "From 10 BTC to 100 BTC", + title: "Above 10 BTC Under 100 BTC", color: colors.fuchsia, }, { - key: "from_100btc_to_1_000btc", + key: "above_100btc_under_1k_btc", name: "100 btc..1K btc", - title: "From 100 BTC to 1K BTC", + title: "Above 100 BTC Under 1K BTC", color: colors.pink, }, { - key: "from_1_000btc_to_10_000btc", + key: "above_1k_btc_under_10k_btc", name: "1K btc..10K btc", - title: "From 1K BTC to 10K BTC", + title: "Above 1K BTC Under 10K BTC", color: colors.red, }, { - key: "from_10_000btc_to_100_000btc", + key: "above_10k_btc_under_100k_btc", name: "10K btc..100K btc", - title: "From 10K BTC to 100K BTC", + title: "Above 10K BTC Under 100K BTC", color: colors.orange, }, { - key: "from_100_000btc", + key: "above_100k_btc", name: "100K btc+", - title: "From 100K BTC", + title: "Above 100K BTC", color: colors.yellow, }, ]); + const utxosAmountRanges = amountRanges.map( + ({ key, name, title, color }) => + /** @type {const} */ ({ + key: `utxos_${key}`, + name, + title: `UTXOs ${title}`, + color, + }), + ); + + const addressesAmountRanges = amountRanges.map( + ({ key, name, title, color }) => + /** @type {const} */ ({ + key: `addrs_${key}`, + name, + title: `Addresses ${title}`, + color, + }), + ); + const type = /** @type {const} */ ([ { key: "p2pk65", @@ -868,7 +946,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.yellow, }, { - key: "p2ms", + key: "p2ms_outputs", name: "p2ms", title: "Pay To Bare Multisig", color: colors.lime, @@ -904,13 +982,13 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.purple, }, { - key: "unknown", + key: "unknown_outputs", name: "unknown", title: "Pay To Unknown", color: colors.violet, }, { - key: "empty", + key: "empty_outputs", name: "empty", title: "Pay To Empty", color: colors.fuchsia, @@ -1019,7 +1097,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.orange, }, { - key: `cumulative_${concat}`, + key: `${concat}_cumulative`, title: name ? `Cumulative ${name}` : "Cumulative", color: colors.red, defaultActive: false, @@ -1419,13 +1497,17 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { const list = "list" in args ? args.list : [args]; const useGroupName = "list" in args; + const title = args.title + ? `${useGroupName ? "by" : "of"} ${args.title}` + : ""; + return /** @satisfies {PartialOptionsGroup} */ ({ name: args.name || "all", tree: [ !("list" in args) ? { name: "supply", - title: `${args.title} Supply`, + title: `Supply ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -1564,7 +1646,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { tree: [ { name: "total", - title: `${args.title} Supply`, + title: `Supply ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -1597,7 +1679,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "in profit", - title: `${args.title} Supply In Profit`, + title: `Supply In Profit ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -1635,7 +1717,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "in loss", - title: `${args.title} Supply In loss`, + title: `Supply In loss ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -1673,7 +1755,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "even", - title: `${args.title} Supply Even`, + title: `Even Supply ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -1713,7 +1795,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "utxo count", - title: `${args.title} UTXO Count`, + title: `UTXO Count ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -1736,7 +1818,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ? [ { name: "address count", - title: `${args.title} Loaded Address Count`, + title: `Address Count ${title}`, bottom: list.flatMap(({ name, color, key: _key }) => { const key = fixKey(_key); return [ @@ -1769,11 +1851,10 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { tree: [ { name: "loaded", - title: `${args.title} Loaded Address Count`, + title: `Loaded Address Count ${title}`, bottom: list .filter( ({ key }) => - key !== "empty" && `${fixKey(key)}address_count` in vecIdToIndexes, ) .flatMap(({ name, color, key: _key }) => { @@ -1794,7 +1875,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ? [ { name: "empty", - title: `${args.title} Empty Address Count`, + title: `Empty Address Count ${title}`, bottom: list .filter( ({ key }) => @@ -1818,41 +1899,12 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, ] : []), - // list.filter(({ key }) => key.endsWith("address_count")).map(callbackfn), - // { - // name: "loaded", - // title: `${args.title} Loaded Address Count`, - // bottom: list.flatMap(({ color, name, key: _key }) => { - // const key = fixKey(_key); - // return /** @type {const} */ ([ - // createBaseSeries({ - // key: `${key}address_count`, - // name: useGroupName ? name : "Loaded", - // color, - // }), - // createBaseSeries({ - // key: `${key}empty_address_count`, - // name: useGroupName ? name : "Empty", - // color, - // }), - // ]); - // }), - // }, - // { - // name: "empty", - // title: `${args.title} Empty Address Count`, - // bottom: list.flatMap(({ color, name, key: _key }) => { - // const key = fixKey(_key); - // return /** @type {const} */ ([ - // ]); - // }), - // }, { name: "Realized", tree: [ { name: "cap", - title: `${args.title} Realized Capitalization`, + title: `Realized Capitalization ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -1882,7 +1934,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { "list" in args ? { name: "Price", - title: `${args.title} Realized Prices`, + title: `Realized Price ${title}`, top: args.list.map(({ color, name, key }) => createBaseSeries({ key: `${fixKey(key)}realized_price`, @@ -1892,7 +1944,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ), } : createPriceWithRatio({ - title: `${args.title} Realized Price`, + title: `Realized Price ${title}`, key: `${fixKey(args.key)}realized_price`, name: "price", legend: "realized", @@ -1902,7 +1954,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ? [ { name: "pnl", - title: `${args.title} Realized Profit And Loss`, + title: `Realized Profit And Loss ${title}`, bottom: [ createBaseSeries({ key: `${fixKey(args.key)}realized_profit`, @@ -1910,7 +1962,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.green, }), createBaseSeries({ - key: `cumulative_${fixKey(args.key)}realized_profit`, + key: `${fixKey(args.key)}realized_profit_cumulative`, name: "Cumulative Profit", color: colors.green, defaultActive: false, @@ -1922,7 +1974,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { defaultActive: false, }), createBaseSeries({ - key: `cumulative_${fixKey(args.key)}realized_loss`, + key: `${fixKey(args.key)}realized_loss_cumulative`, name: "Cumulative Loss", color: colors.red, defaultActive: false, @@ -1933,9 +1985,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.red, }), createBaseSeries({ - key: `cumulative_${fixKey( + key: `${fixKey( args.key, - )}negative_realized_loss`, + )}negative_realized_loss_cumulative`, name: "Cumulative Negative Loss", color: colors.red, defaultActive: false, @@ -1970,7 +2022,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "Net pnl", - title: `${args.title} Net Realized Profit And Loss`, + title: `Net Realized Profit And Loss ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", @@ -1984,9 +2036,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss`, + )}net_realized_profit_and_loss_cumulative`, title: "Cumulative net", defaultActive: false, options: { @@ -1997,9 +2049,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss_30d_change`, + )}net_realized_profit_and_loss_cumulative_30d_change`, title: "cum net 30d change", defaultActive: false, options: { @@ -2022,9 +2074,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss_30d_change_relative_to_realized_cap`, + )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap`, title: "cum net 30d change", options: { createPriceLine: { @@ -2034,10 +2086,10 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss_30d_change_relative_to_market_cap`, - title: "cum net 30d change", + )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap`, + title: "cumulative net 30d change", options: { createPriceLine: { value: 0, @@ -2048,7 +2100,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "sopr", - title: `${args.title} Spent Output Profit Ratio`, + title: `Spent Output Profit Ratio ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", @@ -2077,7 +2129,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { : [ { name: "profit", - title: `${args.title} Realized Profit`, + title: `Realized Profit ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2102,7 +2154,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "loss", - title: `${args.title} Realized Loss`, + title: `Realized Loss ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2127,7 +2179,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "Net pnl", - title: `${args.title} Net Realized Profit And Loss`, + title: `Net Realized Profit And Loss ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", @@ -2160,12 +2212,12 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { tree: [ { name: "profit", - title: `Cumulative ${args.title} Realized Profit`, + title: `Cumulative Realized Profit ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ - key: `cumulative_${key}realized_profit`, + key: `${key}realized_profit_cumulative`, name, color, }), @@ -2174,12 +2226,12 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "loss", - title: `Cumulative ${args.title} Realized Loss`, + title: `Cumulative Realized Loss ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ createBaseSeries({ - key: `cumulative_${key}realized_loss`, + key: `${key}realized_loss_cumulative`, name, color, }), @@ -2188,13 +2240,13 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "Net pnl", - title: `Cumulative ${args.title} Net Realized Profit And Loss`, + title: `Cumulative Net Realized Profit And Loss ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss`, + )}net_realized_profit_and_loss_cumulative`, title: name, color, defaultActive: false, @@ -2208,13 +2260,13 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "Net pnl 30d change", - title: `Cumulative ${args.title} Net Realized Profit And Loss 30 Day Change`, + title: `Cumulative Net Realized Profit And Loss 30 Day Change ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss_30d_change`, + )}net_realized_profit_and_loss_cumulative_30d_change`, title: name, color, options: { @@ -2225,9 +2277,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss_30d_change_relative_to_realized_cap`, + )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_realized_cap`, title: name, color, options: { @@ -2238,9 +2290,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }), /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", - key: `cumulative_${fixKey( + key: `${fixKey( key, - )}net_realized_profit_and_loss_30d_change_relative_to_market_cap`, + )}net_realized_profit_and_loss_cumulative_30d_change_relative_to_market_cap`, title: name, color, options: { @@ -2258,7 +2310,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { tree: [ { name: "Normal", - title: `${args.title} Spent Output Profit Ratio`, + title: `Spent Output Profit Ratio ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", @@ -2275,7 +2327,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "Adjusted", - title: `${args.title} Adjusted Spent Output Profit Ratio`, + title: `Adjusted Spent Output Profit Ratio ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", @@ -2297,7 +2349,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ]), { name: "Sell Side Risk Ratio", - title: `${args.title} Sell Side Risk Ratio`, + title: `Sell Side Risk Ratio ${title}`, bottom: list.flatMap(({ color, name, key }) => createBaseSeries({ key: `${fixKey(key)}sell_side_risk_ratio`, @@ -2315,7 +2367,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ? [ { name: "pnl", - title: `${args.title} Unrealized Profit And Loss`, + title: `Unrealized Profit And Loss ${title}`, bottom: [ // createBaseSeries({ // key: `0`, @@ -2347,7 +2399,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { : [ { name: "profit", - title: `${args.title} Unrealized Profit`, + title: `Unrealized Profit ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2361,7 +2413,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "loss", - title: `${args.title} Unrealized Loss`, + title: `Unrealized Loss ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2376,7 +2428,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ]), { name: "Net pnl", - title: `${args.title} Net Unrealized Profit And Loss`, + title: `Net Unrealized Profit And Loss ${title}`, bottom: list.flatMap(({ color, name, key }) => [ /** @satisfies {FetchedBaselineSeriesBlueprint} */ ({ type: "Baseline", @@ -2413,7 +2465,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { tree: [ { name: "Average", - title: `${args.title} Average Price Paid`, + title: `Average Price Paid ${title}`, top: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2427,7 +2479,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "Min", - title: `${args.title} Min Price Paid`, + title: `Min Price Paid ${title}`, top: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2441,7 +2493,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { }, { name: "Max", - title: `${args.title} Max Price Paid`, + title: `Max Price Paid ${title}`, top: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2459,7 +2511,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { : [ { name: "Price paid", - title: `${args.title} Prices Paid`, + title: `Prices Paid ${title}`, top: [ createBaseSeries({ key: `${fixKey(args.key)}realized_price`, @@ -2483,7 +2535,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { ]), { name: "Coins Destroyed", - title: `${args.title} Coins Destroyed`, + title: `Coins Destroyed ${title}`, bottom: list.flatMap(({ color, name, key: _key }) => { const key = fixKey(_key); return /** @type {const} */ ([ @@ -2493,7 +2545,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color, }), createBaseSeries({ - key: `cumulative_${key}coinblocks_destroyed`, + key: `${key}coinblocks_destroyed_cumulative`, name: useGroupName ? name : "cumulative", color, defaultActive: false, @@ -2504,7 +2556,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color, }), createBaseSeries({ - key: `cumulative_${key}coindays_destroyed`, + key: `${key}coindays_destroyed_cumulative`, name: useGroupName ? name : "cumulative", color, defaultActive: false, @@ -2846,7 +2898,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { title: "Circulating Supply", bottom: [ createBaseSeries({ - key: "cumulative_subsidy_in_btc", + key: "subsidy_in_btc_cumulative", name: "Mined", }), ], @@ -3362,183 +3414,135 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.orange, }), { - name: "term", + name: "terms", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare By Term", + title: "UTXOs Term", list: terms, }), ...terms.map(createCohortGroupFolder), ], }, { - name: "Up to date", + name: "Epochs", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare By Up To", - list: upToDate, - }), - ...upToDate.map(createCohortGroupFolder), - ], - }, - { - name: "From Date", - tree: [ - createCohortGroupFolder({ - name: "Compare", - title: "Compare By From", - list: fromDate, - }), - ...fromDate.map(createCohortGroupFolder), - ], - }, - { - name: "Date Range", - tree: [ - createCohortGroupFolder({ - name: "Compare", - title: "Compare By Range", - list: dateRange, - }), - ...dateRange.map(createCohortGroupFolder), - ], - }, - { - name: "Epoch", - tree: [ - createCohortGroupFolder({ - name: "Compare", - title: "Compare By Epoch", + title: "Epoch", list: epoch, }), ...epoch.map(createCohortGroupFolder), ], }, { - name: "type", + name: "types", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare By Type", + title: "Type", list: type, }), ...type.map(createCohortGroupFolder), ], }, { - name: "UTXOs Up to size", + name: "UTXOs Up to age", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare UTXOs By Up To Size", - list: upToSize, + title: "UTXOs Up To Age", + list: upToDate, }), - ...upToSize.map(createCohortGroupFolder), + ...upToDate.map(createCohortGroupFolder), ], }, { - name: "UTXOs From size", + name: "UTXOs at least age", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare UTXOs By From Size", - list: fromSize, + title: "UTXOs at least age", + list: fromDate, }), - ...fromSize.map(createCohortGroupFolder), + ...fromDate.map(createCohortGroupFolder), ], }, { - name: "UTXOs Size range", + name: "UTXOs age Ranges", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare UTXOs By Size Range", - list: sizeRanges, + title: "UTXOs Age Range", + list: dateRange, }), - ...sizeRanges.map(createCohortGroupFolder), + ...dateRange.map(createCohortGroupFolder), ], }, { - name: "Addresses Up to size", + name: "UTXOs under amounts", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare Addresses By Up To Size", - list: upToSize.map( - (obj) => - /** @type {const} */ ({ - ...obj, - key: `addresses_${obj.key}`, - title: `Addresses ${obj.title}`, - }), - ), + title: "UTXOs under amount", + list: utxosUnderAmount, }), - ...upToSize - .map( - (obj) => - /** @type {const} */ ({ - ...obj, - key: `addresses_${obj.key}`, - title: `Addresses ${obj.title}`, - }), - ) - .map(createCohortGroupFolder), + ...utxosUnderAmount.map(createCohortGroupFolder), ], }, { - name: "Addresses From size", + name: "UTXOs Above Amounts", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare Addresses By From Size", - list: fromSize.map( - (obj) => - /** @type {const} */ ({ - ...obj, - key: `addresses_${obj.key}`, - title: `Addresses ${obj.title}`, - }), - ), + title: "UTXOs Above Amount", + list: utxosAboveAmount, }), - ...fromSize - .map( - (obj) => - /** @type {const} */ ({ - ...obj, - key: `addresses_${obj.key}`, - title: `Addresses ${obj.title}`, - }), - ) - .map(createCohortGroupFolder), + ...utxosAboveAmount.map(createCohortGroupFolder), ], }, { - name: "Addresses Size range", + name: "UTXOs between amounts", tree: [ createCohortGroupFolder({ name: "Compare", - title: "Compare Addresses By Size Range", - list: sizeRanges.map( - (obj) => - /** @type {const} */ ({ - ...obj, - key: `addresses_${obj.key}`, - title: `Addresses ${obj.title}`, - }), - ), + title: "UTXOs between amounts", + list: utxosAmountRanges, }), - ...sizeRanges - .map( - (obj) => - /** @type {const} */ ({ - ...obj, - key: `addresses_${obj.key}`, - title: `Addresses ${obj.title}`, - }), - ) - .map(createCohortGroupFolder), + ...utxosAmountRanges.map(createCohortGroupFolder), + ], + }, + { + name: "Addresses under amount", + tree: [ + createCohortGroupFolder({ + name: "Compare", + title: "Addresses under Amount", + list: addressesUnderAmount, + }), + ...addressesUnderAmount.map(createCohortGroupFolder), + ], + }, + { + name: "Addresses above amount", + tree: [ + createCohortGroupFolder({ + name: "Compare", + title: "Addresses above amount", + list: addressesAboveAmount, + }), + ...addressesAboveAmount.map(createCohortGroupFolder), + ], + }, + { + name: "Addresses between amounts", + tree: [ + createCohortGroupFolder({ + name: "Compare", + title: "Addresses between amounts", + list: addressesAmountRanges, + }), + ...addressesAmountRanges.map(createCohortGroupFolder), ], }, ], @@ -3577,7 +3581,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { name: "sum", }), createBaseSeries({ - key: "cumulative_opreturn_count", + key: "opreturn_count_cumulative", name: "cumulative", color: colors.red, }), @@ -3618,7 +3622,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.red, }), createBaseSeries({ - key: "cumulative_coinblocks_destroyed", + key: "coinblocks_destroyed_cumulative", name: "Cumulative Destroyed", color: colors.red, defaultActive: false, @@ -3629,7 +3633,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.orange, }), createBaseSeries({ - key: "cumulative_coinblocks_created", + key: "coinblocks_created_cumulative", name: "Cumulative created", color: colors.orange, defaultActive: false, @@ -3640,7 +3644,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) { color: colors.green, }), createBaseSeries({ - key: "cumulative_coinblocks_stored", + key: "coinblocks_stored_cumulative", name: "Cumulative stored", color: colors.green, defaultActive: false, @@ -3938,6 +3942,9 @@ export function initOptions({ */ function arrayToRecord(id, arr = []) { return (arr || []).reduce((record, blueprint) => { + if (env.localhost && !(blueprint.key in vecIdToIndexes)) { + throw Error(`${blueprint.key} not recognized`); + } const unit = utils.vecidToUnit(blueprint.key); record[unit] ??= []; record[unit].push(blueprint);