diff --git a/crates/brk_computer/src/vecs/stateful/address_cohorts.rs b/crates/brk_computer/src/vecs/stateful/address_cohorts.rs index f73a3b30e..4456e80c5 100644 --- a/crates/brk_computer/src/vecs/stateful/address_cohorts.rs +++ b/crates/brk_computer/src/vecs/stateful/address_cohorts.rs @@ -186,9 +186,9 @@ impl Vecs { )?, }, by_up_to_size: GroupedByUpToSize { - _1_000sats: address_cohort::Vecs::forced_import( + _10sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_1_000sats"), + Some("addresses_up_to_10sats"), _computation, format, version + VERSION + Version::ZERO, @@ -196,9 +196,59 @@ impl Vecs { states_path, true, )?, - _10_000sats: address_cohort::Vecs::forced_import( + _100sats: address_cohort::Vecs::forced_import( path, - Some("addresses_up_to_10_000sats"), + Some("addresses_up_to_100sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_1k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_10k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_100k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_1m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10m_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_10m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -236,11 +286,111 @@ impl Vecs { states_path, true, )?, + _1k_btc: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_1k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_btc: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_10k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_btc: address_cohort::Vecs::forced_import( + path, + Some("addresses_up_to_100k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, }, by_from_size: GroupedByFromSize { - _1_000sats: address_cohort::Vecs::forced_import( + _1sat: address_cohort::Vecs::forced_import( path, - Some("addresses_from_1_000sats"), + Some("addresses_from_1sat"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_10sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_100sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1k_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_1k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_10k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _100k_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_100k_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _1m_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_1m_sats"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10m_sats: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_10m_sats"), _computation, format, version + VERSION + Version::ZERO, @@ -278,6 +428,26 @@ impl Vecs { states_path, true, )?, + _1k_btc: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_1k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, + _10k_btc: address_cohort::Vecs::forced_import( + path, + Some("addresses_from_10k_btc"), + _computation, + format, + version + VERSION + Version::ZERO, + fetched, + states_path, + true, + )?, }, } .into(), 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 3181d4a5f..c16ccc152 100644 --- a/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount.rs +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount.rs @@ -2,13 +2,13 @@ use brk_core::{GroupedByAddressType, Height}; use brk_vec::VecIterator; use derive_deref::{Deref, DerefMut}; -use crate::vecs::stateful::addresstype_to_addresscount_vec::AddressTypeToAddressCountVec; +use crate::vecs::stateful::addresstype_to_height_to_addresscount::AddressTypeToHeightToAddressCount; #[derive(Debug, Default, Deref, DerefMut)] pub struct AddressTypeToAddressCount(GroupedByAddressType); -impl From<(&AddressTypeToAddressCountVec, Height)> for AddressTypeToAddressCount { - fn from((groups, starting_height): (&AddressTypeToAddressCountVec, Height)) -> Self { +impl From<(&AddressTypeToHeightToAddressCount, Height)> for AddressTypeToAddressCount { + fn from((groups, starting_height): (&AddressTypeToHeightToAddressCount, Height)) -> Self { if let Some(prev_height) = starting_height.decremented() { Self(GroupedByAddressType { p2pk65: groups diff --git a/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount_vec.rs b/crates/brk_computer/src/vecs/stateful/addresstype_to_height_to_addresscount.rs similarity index 84% rename from crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount_vec.rs rename to crates/brk_computer/src/vecs/stateful/addresstype_to_height_to_addresscount.rs index 10c27333b..9075092e3 100644 --- a/crates/brk_computer/src/vecs/stateful/addresstype_to_addresscount_vec.rs +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_height_to_addresscount.rs @@ -6,15 +6,17 @@ use derive_deref::{Deref, DerefMut}; use crate::vecs::stateful::addresstype_to_addresscount::AddressTypeToAddressCount; #[derive(Debug, Clone, Deref, DerefMut)] -pub struct AddressTypeToAddressCountVec(GroupedByAddressType>); +pub struct AddressTypeToHeightToAddressCount(GroupedByAddressType>); -impl From>> for AddressTypeToAddressCountVec { +impl From>> + for AddressTypeToHeightToAddressCount +{ fn from(value: GroupedByAddressType>) -> Self { Self(value) } } -impl AddressTypeToAddressCountVec { +impl AddressTypeToHeightToAddressCount { pub fn forced_push_at( &mut self, height: Height, 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 new file mode 100644 index 000000000..1011cb9a7 --- /dev/null +++ b/crates/brk_computer/src/vecs/stateful/addresstype_to_indexes_to_addresscount.rs @@ -0,0 +1,91 @@ +use brk_core::{GroupedByAddressType, StoredUsize}; +use brk_exit::Exit; +use brk_vec::AnyCollectableVec; +use derive_deref::{Deref, DerefMut}; + +use crate::vecs::{ + Indexes, grouped::ComputedVecsFromHeight, indexes, + stateful::addresstype_to_height_to_addresscount::AddressTypeToHeightToAddressCount, +}; + +#[derive(Clone, Deref, DerefMut)] +pub struct AddressTypeToIndexesToAddressCount( + GroupedByAddressType>, +); + +impl From>> + for AddressTypeToIndexesToAddressCount +{ + fn from(value: GroupedByAddressType>) -> Self { + Self(value) + } +} + +impl AddressTypeToIndexesToAddressCount { + pub fn compute( + &mut self, + // height: Height, + indexes: &indexes::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + addresstype_to_height_to_addresscount: &AddressTypeToHeightToAddressCount, + ) -> color_eyre::Result<()> { + self.p2pk65.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2pk65), + )?; + self.p2pk33.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2pk33), + )?; + self.p2pkh.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2pkh), + )?; + self.p2sh.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2sh), + )?; + self.p2wpkh.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2wpkh), + )?; + self.p2wsh.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2wsh), + )?; + self.p2tr.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2tr), + )?; + self.p2a.compute_rest( + indexes, + starting_indexes, + exit, + Some(&addresstype_to_height_to_addresscount.p2a), + )?; + Ok(()) + } + // + pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> { + self.0 + .as_typed_vec() + .into_iter() + .flat_map(|(_, v)| v.vecs()) + .collect::>() + } +} diff --git a/crates/brk_computer/src/vecs/stateful/mod.rs b/crates/brk_computer/src/vecs/stateful/mod.rs index c48d63a4c..a3f6aa740 100644 --- a/crates/brk_computer/src/vecs/stateful/mod.rs +++ b/crates/brk_computer/src/vecs/stateful/mod.rs @@ -21,7 +21,9 @@ use crate::{ market, stateful::{ addresstype_to_addresscount::AddressTypeToAddressCount, - addresstype_to_addresscount_vec::AddressTypeToAddressCountVec, r#trait::DynCohortVecs, + addresstype_to_height_to_addresscount::AddressTypeToHeightToAddressCount, + addresstype_to_indexes_to_addresscount::AddressTypeToIndexesToAddressCount, + r#trait::DynCohortVecs, }, }, }; @@ -35,7 +37,8 @@ use super::{ mod address_cohort; mod address_cohorts; mod addresstype_to_addresscount; -mod addresstype_to_addresscount_vec; +mod addresstype_to_height_to_addresscount; +mod addresstype_to_indexes_to_addresscount; mod addresstype_to_typeindex_tree; mod addresstype_to_typeindex_vec; mod common; @@ -59,8 +62,10 @@ pub struct Vecs { pub indexes_to_unspendable_supply: ComputedValueVecsFromHeight, pub height_to_opreturn_supply: EagerVec, pub indexes_to_opreturn_supply: ComputedValueVecsFromHeight, - pub addresstype_to_height_to_address_count: AddressTypeToAddressCountVec, - pub addresstype_to_height_to_empty_address_count: AddressTypeToAddressCountVec, + pub addresstype_to_height_to_address_count: AddressTypeToHeightToAddressCount, + pub addresstype_to_height_to_empty_address_count: AddressTypeToHeightToAddressCount, + pub addresstype_to_indexes_to_address_count: AddressTypeToIndexesToAddressCount, + pub addresstype_to_indexes_to_empty_address_count: AddressTypeToIndexesToAddressCount, pub utxo_vecs: utxo_cohorts::Vecs, pub address_vecs: address_cohorts::Vecs, @@ -137,7 +142,7 @@ impl Vecs { format, StorableVecGeneatorOptions::default().add_last(), )?, - addresstype_to_height_to_address_count: AddressTypeToAddressCountVec::from( + addresstype_to_height_to_address_count: AddressTypeToHeightToAddressCount::from( GroupedByAddressType { p2pk65: EagerVec::forced_import( path, @@ -189,7 +194,7 @@ impl Vecs { )?, }, ), - addresstype_to_height_to_empty_address_count: AddressTypeToAddressCountVec::from( + addresstype_to_height_to_empty_address_count: AddressTypeToHeightToAddressCount::from( GroupedByAddressType { p2pk65: EagerVec::forced_import( path, @@ -241,6 +246,142 @@ impl Vecs { )?, }, ), + addresstype_to_indexes_to_address_count: AddressTypeToIndexesToAddressCount::from( + GroupedByAddressType { + p2pk65: ComputedVecsFromHeight::forced_import( + path, + "p2pk65_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2pk33: ComputedVecsFromHeight::forced_import( + path, + "p2pk33_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2pkh: ComputedVecsFromHeight::forced_import( + path, + "p2pkh_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2sh: ComputedVecsFromHeight::forced_import( + path, + "p2sh_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2wpkh: ComputedVecsFromHeight::forced_import( + path, + "p2wpkh_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2wsh: ComputedVecsFromHeight::forced_import( + path, + "p2wsh_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2tr: ComputedVecsFromHeight::forced_import( + path, + "p2tr_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2a: ComputedVecsFromHeight::forced_import( + path, + "p2a_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + }, + ), + addresstype_to_indexes_to_empty_address_count: AddressTypeToIndexesToAddressCount::from( + GroupedByAddressType { + p2pk65: ComputedVecsFromHeight::forced_import( + path, + "p2pk65_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2pk33: ComputedVecsFromHeight::forced_import( + path, + "p2pk33_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2pkh: ComputedVecsFromHeight::forced_import( + path, + "p2pkh_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2sh: ComputedVecsFromHeight::forced_import( + path, + "p2sh_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2wpkh: ComputedVecsFromHeight::forced_import( + path, + "p2wpkh_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2wsh: ComputedVecsFromHeight::forced_import( + path, + "p2wsh_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2tr: ComputedVecsFromHeight::forced_import( + path, + "p2tr_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + p2a: ComputedVecsFromHeight::forced_import( + path, + "p2a_empty_address_count", + false, + version + VERSION + Version::ZERO, + format, + StorableVecGeneatorOptions::default().add_last(), + )?, + }, + ), utxo_vecs: utxo_cohorts::Vecs::forced_import( path, version, @@ -1084,6 +1225,19 @@ impl Vecs { }, )?; + self.addresstype_to_indexes_to_address_count.compute( + indexes, + starting_indexes, + exit, + &self.addresstype_to_height_to_address_count, + )?; + self.addresstype_to_indexes_to_empty_address_count.compute( + indexes, + starting_indexes, + exit, + &self.addresstype_to_height_to_empty_address_count, + )?; + thread::scope(|scope| { scope.spawn(|| { self.utxo_vecs @@ -1241,6 +1395,8 @@ impl Vecs { self.indexes_to_opreturn_supply.vecs(), self.indexes_to_address_count.vecs(), self.indexes_to_empty_address_count.vecs(), + self.addresstype_to_indexes_to_address_count.vecs(), + self.addresstype_to_indexes_to_empty_address_count.vecs(), self.addresstype_to_height_to_address_count .as_typed_vec() .into_iter() diff --git a/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs b/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs index 5ae916c57..bb8885136 100644 --- a/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs +++ b/crates/brk_computer/src/vecs/stateful/utxo_cohorts.rs @@ -827,9 +827,9 @@ impl Vecs { )?, }, by_up_to_size: GroupedByUpToSize { - _1_000sats: utxo_cohort::Vecs::forced_import( + _10sats: utxo_cohort::Vecs::forced_import( path, - Some("up_to_1_000sats"), + Some("up_to_10sats"), _computation, format, version + VERSION + Version::ZERO, @@ -837,9 +837,59 @@ impl Vecs { states_path, true, )?, - _10_000sats: utxo_cohort::Vecs::forced_import( + _100sats: utxo_cohort::Vecs::forced_import( path, - Some("up_to_10_000sats"), + 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, @@ -877,11 +927,111 @@ impl Vecs { 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 { - _1_000sats: utxo_cohort::Vecs::forced_import( + _1sat: utxo_cohort::Vecs::forced_import( path, - Some("from_1_000sats"), + 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, @@ -919,6 +1069,26 @@ impl Vecs { 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 { p2pk65: utxo_cohort::Vecs::forced_import( diff --git a/crates/brk_core/src/groups/by_from_size.rs b/crates/brk_core/src/groups/by_from_size.rs index 23d338706..851105100 100644 --- a/crates/brk_core/src/groups/by_from_size.rs +++ b/crates/brk_core/src/groups/by_from_size.rs @@ -4,30 +4,57 @@ use super::GroupFilter; #[derive(Default, Clone)] pub struct GroupedByFromSize { - pub _1_000sats: T, + 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; 4] { + pub fn as_mut_vec(&mut self) -> [&mut T; 13] { [ - &mut self._1_000sats, + &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; 4] { + pub fn vecs(&self) -> [&T; 13] { [ - &self._1_000sats.1, + &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, ] } } @@ -35,16 +62,19 @@ impl GroupedByFromSize<(GroupFilter, T)> { impl From> for GroupedByFromSize<(GroupFilter, T)> { fn from(value: GroupedByFromSize) -> Self { Self { - _1_000sats: (GroupFilter::From(1_000), value._1_000sats), - _1btc: (GroupFilter::From(usize::from(Sats::ONE_BTC)), value._1btc), - _10btc: ( - GroupFilter::From(usize::from(10 * Sats::ONE_BTC)), - value._10btc, - ), - _100btc: ( - GroupFilter::From(usize::from(100 * Sats::ONE_BTC)), - value._100btc, - ), + _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_size_range.rs b/crates/brk_core/src/groups/by_size_range.rs index fe903bf24..9c7668376 100644 --- a/crates/brk_core/src/groups/by_size_range.rs +++ b/crates/brk_core/src/groups/by_size_range.rs @@ -98,11 +98,11 @@ impl GroupedBySizeRange { &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::_1_BTC { + } else if value < Sats::_1BTC { &mut self.from_10_000_000sats_to_1btc - } else if value < Sats::_10_BTC { + } else if value < Sats::_10BTC { &mut self.from_1btc_to_10btc - } else if value < Sats::_100_BTC { + } else if value < Sats::_100BTC { &mut self.from_10btc_to_100btc } else if value < Sats::_1K_BTC { &mut self.from_100btc_to_1_000btc @@ -146,9 +146,9 @@ impl GroupedBySizeRange { (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::_1_BTC, &self.from_1btc_to_10btc), - (Sats::_10_BTC, &self.from_10btc_to_100btc), - (Sats::_100_BTC, &self.from_100btc_to_1_000btc), + (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), diff --git a/crates/brk_core/src/groups/by_up_to_size.rs b/crates/brk_core/src/groups/by_up_to_size.rs index 2bb189c6d..feb977085 100644 --- a/crates/brk_core/src/groups/by_up_to_size.rs +++ b/crates/brk_core/src/groups/by_up_to_size.rs @@ -4,33 +4,57 @@ use super::GroupFilter; #[derive(Default, Clone)] pub struct GroupedByUpToSize { - pub _1_000sats: T, - pub _10_000sats: 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, + pub _100k_btc: T, } impl GroupedByUpToSize { - pub fn as_mut_vec(&mut self) -> [&mut T; 5] { + pub fn as_mut_vec(&mut self) -> [&mut T; 13] { [ - &mut self._1_000sats, - &mut self._10_000sats, + &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; 5] { + pub fn vecs(&self) -> [&T; 13] { [ - &self._1_000sats.1, - &self._10_000sats.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, + &self._100k_btc.1, ] } } @@ -38,17 +62,19 @@ impl GroupedByUpToSize<(GroupFilter, T)> { impl From> for GroupedByUpToSize<(GroupFilter, T)> { fn from(value: GroupedByUpToSize) -> Self { Self { - _1_000sats: (GroupFilter::To(1_000), value._1_000sats), - _10_000sats: (GroupFilter::To(10_000), value._10_000sats), - _1btc: (GroupFilter::To(usize::from(Sats::ONE_BTC)), value._1btc), - _10btc: ( - GroupFilter::To(usize::from(10 * Sats::ONE_BTC)), - value._10btc, - ), - _100btc: ( - GroupFilter::To(usize::from(100 * Sats::ONE_BTC)), - value._100btc, - ), + _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/structs/sats.rs b/crates/brk_core/src/structs/sats.rs index 724c55324..4905e592e 100644 --- a/crates/brk_core/src/structs/sats.rs +++ b/crates/brk_core/src/structs/sats.rs @@ -44,9 +44,9 @@ impl Sats { pub const _100K: Self = Self(100_000); pub const _1M: Self = Self(1_000_000); pub const _10M: Self = Self(10_000_000); - pub const _1_BTC: Self = Self::ONE_BTC; - pub const _10_BTC: Self = Self(10_00_000_000); - pub const _100_BTC: Self = Self(100_00_000_000); + pub const _1BTC: Self = Self::ONE_BTC; + pub const _10BTC: Self = Self(10_00_000_000); + pub const _100BTC: Self = Self(100_00_000_000); pub const _1K_BTC: Self = Self(1_000_00_000_000); pub const _10K_BTC: Self = Self(10_000_00_000_000); pub const _100K_BTC: Self = Self(100_000_00_000_000); diff --git a/crates/brk_indexer/src/stores.rs b/crates/brk_indexer/src/stores.rs index a740c91b0..024bba8f8 100644 --- a/crates/brk_indexer/src/stores.rs +++ b/crates/brk_indexer/src/stores.rs @@ -163,9 +163,9 @@ impl Stores { self.as_slice() .into_iter() .map(|store| { - let height = store.height().map(Height::incremented).unwrap_or_default(); + // let height = + store.height().map(Height::incremented).unwrap_or_default() // dbg!((height, store.name())); - height }) .min() .unwrap() diff --git a/crates/brk_server/src/api/interface/bridge.rs b/crates/brk_server/src/api/interface/bridge.rs index f97d11dc9..a70c8b747 100644 --- a/crates/brk_server/src/api/interface/bridge.rs +++ b/crates/brk_server/src/api/interface/bridge.rs @@ -52,7 +52,7 @@ export const VERSION = \"v{VERSION}\"; .join("\n"); contents += &format!( - "\n\n/** @typedef {{{}}} Index */", + "\n\n/** @typedef {{{}}} Index */\n", indexes .iter() .map(|i| i.to_string()) @@ -60,10 +60,16 @@ export const VERSION = \"v{VERSION}\"; .join(" | ") ); - contents += "\n\n/** @typedef {ReturnType} VecIdToIndexes */"; - contents += "\n/** @typedef {keyof VecIdToIndexes} VecId */\n"; + contents += " +/** @typedef {ReturnType} VecIdToIndexes +/** @typedef {keyof VecIdToIndexes} VecId */ +"; - contents += "\nexport function createVecIdToIndexes() {\n"; + contents += " +/** + * @returns {Record} + */ +export function createVecIdToIndexes() {\n"; contents += " return {\n"; diff --git a/websites/default/index.html b/websites/default/index.html index 016031457..666c1b12a 100644 --- a/websites/default/index.html +++ b/websites/default/index.html @@ -1382,8 +1382,8 @@ overflow: hidden; font-size: var(--font-size-sm); line-height: var(--line-height-sm); - --color: var(--dark-gray); - color: var(--white); + --face-color: var(--border-color); + color: var(--color); .face { transform-origin: 0 0; @@ -1393,16 +1393,17 @@ padding: 0.1rem; } .right { - background-color: var(--color); + background-color: oklch( + from var(--face-color) calc(l - 0.05) c h + ); transform: rotate(-30deg) skewX(-30deg) translate(calc(var(--cube) * 1.3), calc(var(--cube) * 1.725)) scaleY(0.864); } .top { background-color: oklch( - from var(--color) calc(l + 0.122) c calc(h + 6) + from var(--face-color) calc(l + 0.05) c h ); - /* background-color: var(--yellow); */ transform: rotate(30deg) skew(-30deg) translate(calc(var(--cube) * 0.99), calc(var(--cube) * -0.265)) scaleY(0.864); @@ -1418,9 +1419,7 @@ .left { font-size: var(--font-size-xs); line-height: var(--line-height-xs); - background-color: oklch( - from var(--color) calc(l + 0.066) c calc(h + 3) - ); + background-color: var(--face-color); /* background-color: var(--amber); */ transform: rotate(30deg) skewX(30deg) translate(calc(var(--cube) * 0.3), calc(var(--cube) * 0.6)) diff --git a/websites/default/scripts/main.js b/websites/default/scripts/main.js index aa1428c75..62d984e05 100644 --- a/websites/default/scripts/main.js +++ b/websites/default/scripts/main.js @@ -2150,6 +2150,7 @@ function main() { signals, utils, qrcode, + vecIdToIndexes, }); // window.addEventListener("popstate", (_) => { diff --git a/websites/default/scripts/options.js b/websites/default/scripts/options.js index 123928456..a7ddcf1ba 100644 --- a/websites/default/scripts/options.js +++ b/websites/default/scripts/options.js @@ -116,9 +116,10 @@ * @param {Object} args * @param {Env} args.env * @param {Colors} args.colors + * @param {VecIdToIndexes} args.vecIdToIndexes * @returns {PartialOptionsTree} */ -function createPartialOptions({ env, colors }) { +function createPartialOptions({ env, colors, vecIdToIndexes }) { /** * @template {string} S * @typedef {Extract} StartsWith @@ -594,62 +595,164 @@ function createPartialOptions({ env, colors }) { const fromSize = /** @type {const} */ ([ { - key: "from_1_000sats", - name: "1K sats", + key: "from_1sat", + name: ">=1 sat", + title: "From 1 sat", + color: colors.orange, + }, + { + key: "from_10sats", + name: ">=10 sats", + title: "From 10 sats", + color: colors.orange, + }, + { + key: "from_100sats", + name: ">=100 sats", + title: "From 100 sats", + color: colors.yellow, + }, + { + key: "from_1k_sats", + name: ">=1K sats", title: "From 1K sats", + color: colors.lime, + }, + { + key: "from_10k_sats", + name: ">=10K sats", + title: "From 10K sats", + color: colors.green, + }, + { + key: "from_100k_sats", + name: ">=100K sats", + title: "From 100K sats", color: colors.cyan, }, { - key: "from_1btc", - name: "1btc", - title: "From 1 BTC", - color: colors.violet, + key: "from_1m_sats", + name: ">=1M sats", + title: "From 1M sats", + color: colors.blue, }, { - key: "from_10btc", - name: "10btc", - title: "From 10 BTC", + key: "from_10m_sats", + name: ">=10M sats", + title: "From 10M sats", + color: colors.indigo, + }, + { + key: "from_1btc", + name: ">=1 btc", + title: "From 1 BTC", color: colors.purple, }, + { + key: "from_10btc", + name: ">=10 btc", + title: "From 10 BTC", + color: colors.violet, + }, { key: "from_100btc", - name: "100btc", + name: ">=100 btc", title: "From 100 BTC", + color: colors.fuchsia, + }, + { + key: "from_1k_btc", + name: ">=1K btc", + title: "From 1K BTC", color: colors.pink, }, + { + key: "from_10k_btc", + name: ">=10K btc", + title: "From 10K BTC", + color: colors.red, + }, ]); const upToSize = /** @type {const} */ ([ { - key: "up_to_1_000sats", - name: "1K sats", - title: "Up to 1K sats", + key: "up_to_10sats", + name: "<10 sats", + title: "Up to 10 sats", + color: colors.orange, + }, + { + key: "up_to_100sats", + name: "<100 sats", + title: "Up to 100 sats", color: colors.yellow, }, { - key: "up_to_10_000sats", - name: "10K sats", + key: "up_to_1k_sats", + name: "<1K sats", + title: "Up to 1K sats", + color: colors.lime, + }, + { + key: "up_to_10k_sats", + name: "<10K sats", title: "Up to 10K sats", color: colors.green, }, { - key: "up_to_1btc", - name: "1btc", - title: "Up to 1 btc", + key: "up_to_100k_sats", + name: "<100K sats", + title: "Up to 100K sats", color: colors.cyan, }, { - key: "up_to_10btc", - name: "10btc", - title: "Up to 10 btc", + key: "up_to_1m_sats", + name: "<1M sats", + title: "Up to 1M sats", color: colors.blue, }, { - key: "up_to_100btc", - name: "100btc", - title: "Up to 100 btc", + key: "up_to_10m_sats", + name: "<10M sats", + title: "Up to 10M sats", + color: colors.indigo, + }, + { + key: "up_to_1btc", + name: "<1 btc", + title: "up to 1 BTC", + color: colors.purple, + }, + { + key: "up_to_10btc", + name: "<10 btc", + title: "Up to 10 BTC", color: colors.violet, }, + { + key: "up_to_100btc", + name: "<100 btc", + title: "Up to 100 BTC", + color: colors.fuchsia, + }, + { + key: "up_to_1k_btc", + name: "<1K btc", + title: "up to 1K BTC", + color: colors.pink, + }, + { + key: "up_to_10k_btc", + name: "<10K btc", + title: "up to 10K BTC", + color: colors.red, + }, + { + key: "up_to_100k_btc", + name: "<100K btc", + title: "up to 100K BTC", + color: colors.orange, + }, ]); const sizeRanges = /** @type {const} */ ([ @@ -1319,146 +1422,295 @@ function createPartialOptions({ env, colors }) { return /** @satisfies {PartialOptionsGroup} */ ({ name: args.name || "all", tree: [ - { - name: "supply", - title: `${args.title} Supply`, - bottom: list.flatMap(({ color, name, key: _key }) => { - const key = fixKey(_key); - return /** @type {const} */ ([ - createBaseSeries({ - key: `${key}supply`, - name: useGroupName ? name : "Supply", - color: "list" in args ? color : colors.default, + !("list" in args) + ? { + name: "supply", + title: `${args.title} Supply`, + bottom: list.flatMap(({ color, name, key: _key }) => { + const key = fixKey(_key); + return /** @type {const} */ ([ + createBaseSeries({ + key: `${key}supply`, + name: "Supply", + color: colors.default, + }), + createBaseSeries({ + key: `${key}supply_in_btc`, + name: "Supply", + color: colors.default, + }), + createBaseSeries({ + key: `${key}supply_in_usd`, + name: "Supply", + color: colors.default, + }), + ...(key + ? [ + createBaseSeries({ + key: `${key}supply_relative_to_circulating_supply`, + name: "Supply", + color: colors.default, + }), + ] + : []), + createBaseSeries({ + key: `${key}halved_supply`, + name: "Halved", + color: colors.gray, + options: { + lineStyle: 4, + }, + }), + createBaseSeries({ + key: `${key}supply_in_profit`, + name: "In Profit", + color: colors.green, + }), + createBaseSeries({ + key: `${key}supply_in_profit_in_btc`, + name: "In Profit", + color: colors.green, + }), + createBaseSeries({ + key: `${key}supply_in_profit_in_usd`, + name: "In Profit", + color: colors.green, + }), + createBaseSeries({ + key: `${key}supply_in_loss`, + name: "In Loss", + color: colors.red, + }), + createBaseSeries({ + key: `${key}supply_in_loss_in_btc`, + name: "In Loss", + color: colors.red, + }), + createBaseSeries({ + key: `${key}supply_in_loss_in_usd`, + name: "In Loss", + color: colors.red, + }), + createBaseSeries({ + key: `${key}supply_even`, + name: useGroupName ? name : "Even", + color: colors.yellow, + }), + createBaseSeries({ + key: `${key}supply_even_in_btc`, + name: useGroupName ? name : "Even", + color: colors.yellow, + }), + createBaseSeries({ + key: `${key}supply_even_in_usd`, + name: useGroupName ? name : "Even", + color: colors.yellow, + }), + createBaseSeries({ + key: `${key}halved_supply_in_btc`, + name: useGroupName ? name : "Halved", + color: "list" in args ? color : colors.gray, + options: { + lineStyle: 4, + }, + }), + createBaseSeries({ + key: `${key}halved_supply_in_usd`, + name: useGroupName ? name : "Halved", + color: "list" in args ? color : colors.gray, + options: { + lineStyle: 4, + }, + }), + ...(key + ? [ + createBaseSeries({ + key: `${key}supply_in_profit_relative_to_circulating_supply`, + name: "In Profit", + color: colors.green, + }), + createBaseSeries({ + key: `${key}supply_in_loss_relative_to_circulating_supply`, + name: "In Loss", + color: colors.red, + }), + createBaseSeries({ + key: `${key}supply_even_relative_to_circulating_supply`, + name: "Even", + color: colors.yellow, + }), + ] + : []), + createBaseSeries({ + key: `${key}supply_in_profit_relative_to_own_supply`, + name: "In Profit", + color: colors.green, + }), + createBaseSeries({ + key: `${key}supply_in_loss_relative_to_own_supply`, + name: "In Loss", + color: colors.red, + }), + createBaseSeries({ + key: `${key}supply_even_relative_to_own_supply`, + name: "Even", + color: colors.yellow, + }), + ]); }), - createBaseSeries({ - key: `${key}supply_in_btc`, - name: useGroupName ? name : "Supply", - color: "list" in args ? color : colors.default, - }), - createBaseSeries({ - key: `${key}supply_in_usd`, - name: useGroupName ? name : "Supply", - color: "list" in args ? color : colors.default, - }), - ...(key - ? [ - createBaseSeries({ - key: `${key}supply_relative_to_circulating_supply`, - name: useGroupName ? name : "Supply", - color: "list" in args ? color : colors.default, - }), - ] - : []), - ...(!("list" in args) - ? [ - createBaseSeries({ - key: `${key}halved_supply`, - name: useGroupName ? name : "Halved", - color: "list" in args ? color : colors.gray, - options: { - lineStyle: 4, - }, - }), - createBaseSeries({ - key: `${key}supply_in_profit`, - name: useGroupName ? name : "In Profit", - color: colors.green, - }), - createBaseSeries({ - key: `${key}supply_in_loss`, - name: useGroupName ? name : "In Loss", - color: colors.red, - }), - createBaseSeries({ - key: `${key}supply_even`, - name: useGroupName ? name : "Even", - color: colors.yellow, - }), - createBaseSeries({ - key: `${key}halved_supply_in_btc`, - name: useGroupName ? name : "Halved", - color: "list" in args ? color : colors.gray, - options: { - lineStyle: 4, - }, - }), - createBaseSeries({ - key: `${key}supply_in_profit_in_btc`, - name: useGroupName ? name : "In Profit", - color: colors.green, - }), - createBaseSeries({ - key: `${key}supply_in_loss_in_btc`, - name: useGroupName ? name : "In Loss", - color: colors.red, - }), - createBaseSeries({ - key: `${key}supply_even_in_btc`, - name: useGroupName ? name : "Even", - color: colors.yellow, - }), - createBaseSeries({ - key: `${key}halved_supply_in_usd`, - name: useGroupName ? name : "Halved", - color: "list" in args ? color : colors.gray, - options: { - lineStyle: 4, - }, - }), - createBaseSeries({ - key: `${key}supply_in_profit_in_usd`, - name: useGroupName ? name : "In Profit", - color: colors.green, - }), - createBaseSeries({ - key: `${key}supply_in_loss_in_usd`, - name: useGroupName ? name : "In Loss", - color: colors.red, - }), - createBaseSeries({ - key: `${key}supply_even_in_usd`, - name: useGroupName ? name : "Even", - color: colors.yellow, - }), - ...(key - ? [ - createBaseSeries({ - key: `${key}supply_in_profit_relative_to_circulating_supply`, - name: useGroupName ? name : "In Profit", - color: colors.green, - }), - createBaseSeries({ - key: `${key}supply_in_loss_relative_to_circulating_supply`, - name: useGroupName ? name : "In Loss", - color: colors.red, - }), - createBaseSeries({ - key: `${key}supply_even_relative_to_circulating_supply`, - name: useGroupName ? name : "Even", - color: colors.yellow, - }), - ] - : []), - createBaseSeries({ - key: `${key}supply_in_profit_relative_to_own_supply`, - name: useGroupName ? name : "In Profit", - color: colors.green, - }), - createBaseSeries({ - key: `${key}supply_in_loss_relative_to_own_supply`, - name: useGroupName ? name : "In Loss", - color: colors.red, - }), - createBaseSeries({ - key: `${key}supply_even_relative_to_own_supply`, - name: useGroupName ? name : "Even", - color: colors.yellow, - }), - ] - : []), - ]); - }), - }, + } + : { + name: "supply", + tree: [ + { + name: "total", + title: `${args.title} Supply`, + bottom: list.flatMap(({ color, name, key: _key }) => { + const key = fixKey(_key); + return /** @type {const} */ ([ + createBaseSeries({ + key: `${key}supply`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_in_btc`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_in_usd`, + name, + color, + }), + ...(key + ? [ + createBaseSeries({ + key: `${key}supply_relative_to_circulating_supply`, + name, + color, + }), + ] + : []), + ]); + }), + }, + { + name: "in profit", + title: `${args.title} Supply In Profit`, + bottom: list.flatMap(({ color, name, key: _key }) => { + const key = fixKey(_key); + return /** @type {const} */ ([ + createBaseSeries({ + key: `${key}supply_in_profit`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_in_profit_in_btc`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_in_profit_in_usd`, + name, + color, + }), + ...(key + ? [ + createBaseSeries({ + key: `${key}supply_in_profit_relative_to_circulating_supply`, + name, + color, + }), + ] + : []), + createBaseSeries({ + key: `${key}supply_in_profit_relative_to_own_supply`, + name, + color, + }), + ]); + }), + }, + { + name: "in loss", + title: `${args.title} Supply In loss`, + bottom: list.flatMap(({ color, name, key: _key }) => { + const key = fixKey(_key); + return /** @type {const} */ ([ + createBaseSeries({ + key: `${key}supply_in_loss`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_in_loss_in_btc`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_in_loss_in_usd`, + name, + color, + }), + ...(key + ? [ + createBaseSeries({ + key: `${key}supply_in_loss_relative_to_circulating_supply`, + name, + color, + }), + ] + : []), + createBaseSeries({ + key: `${key}supply_in_loss_relative_to_own_supply`, + name, + color, + }), + ]); + }), + }, + { + name: "even", + title: `${args.title} Supply Even`, + bottom: list.flatMap(({ color, name, key: _key }) => { + const key = fixKey(_key); + return /** @type {const} */ ([ + createBaseSeries({ + key: `${key}supply_even`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_even_in_btc`, + name, + color, + }), + createBaseSeries({ + key: `${key}supply_even_in_usd`, + name, + color, + }), + ...(key + ? [ + createBaseSeries({ + key: `${key}supply_even_relative_to_circulating_supply`, + name, + color, + }), + ] + : []), + createBaseSeries({ + key: `${key}supply_even_relative_to_own_supply`, + name, + color, + }), + ]); + }), + }, + ], + }, { name: "utxo count", title: `${args.title} UTXO Count`, @@ -1473,6 +1725,99 @@ function createPartialOptions({ env, colors }) { ]); }), }, + ...(list.filter( + ({ key }) => `${fixKey(key)}address_count` in vecIdToIndexes, + ).length + ? !("list" in args) || + list.filter( + ({ key }) => + `${fixKey(key)}empty_address_count` in vecIdToIndexes, + ).length == 0 + ? [ + { + name: "address count", + title: `${args.title} Loaded Address Count`, + bottom: list.flatMap(({ name, color, key: _key }) => { + const key = fixKey(_key); + return [ + ...(`${key}address_count` in vecIdToIndexes + ? /** @type {const} */ ([ + createBaseSeries({ + key: `${key}address_count`, + name: useGroupName ? name : "Loaded", + color: useGroupName ? color : colors.orange, + }), + ]) + : []), + ...(`${key}empty_address_count` in vecIdToIndexes + ? /** @type {const} */ ([ + createBaseSeries({ + key: `${key}empty_address_count`, + name: "Empty", + color: colors.gray, + defaultActive: false, + }), + ]) + : []), + ]; + }), + }, + ] + : [ + { + name: "address count", + tree: [ + { + name: "loaded", + title: `${args.title} Loaded Address Count`, + bottom: list + .filter( + ({ key }) => + key !== "empty" && + `${fixKey(key)}address_count` in vecIdToIndexes, + ) + .flatMap(({ name, color, key: _key }) => { + const key = fixKey(_key); + return [ + createBaseSeries({ + key: `${key}address_count`, + name, + color, + }), + ]; + }), + }, + ...(list.filter( + ({ key }) => + `${fixKey(key)}empty_address_count` in vecIdToIndexes, + ).length + ? [ + { + name: "empty", + title: `${args.title} Empty Address Count`, + bottom: list + .filter( + ({ key }) => + `${fixKey(key)}empty_address_count` in + vecIdToIndexes, + ) + .flatMap(({ name, color, key: _key }) => { + const key = fixKey(_key); + return [ + createBaseSeries({ + key: `${key}empty_address_count`, + name, + color, + }), + ]; + }), + }, + ] + : []), + ], + }, + ] + : []), // list.filter(({ key }) => key.endsWith("address_count")).map(callbackfn), // { // name: "loaded", @@ -3553,9 +3898,17 @@ function createPartialOptions({ env, colors }) { * @param {Signals} args.signals * @param {Env} args.env * @param {Utilities} args.utils + * @param {VecIdToIndexes} args.vecIdToIndexes * @param {Signal} args.qrcode */ -export function initOptions({ colors, signals, env, utils, qrcode }) { +export function initOptions({ + colors, + signals, + env, + utils, + qrcode, + vecIdToIndexes, +}) { const LS_SELECTED_KEY = `selected_id`; const urlSelected = utils.url.pathnameToSelectedId(); @@ -3564,7 +3917,7 @@ export function initOptions({ colors, signals, env, utils, qrcode }) { /** @type {Signal