From 589337627938a09858ab037842a637a0f66c8c91 Mon Sep 17 00:00:00 2001 From: nym21 Date: Mon, 19 May 2025 17:53:09 +0200 Subject: [PATCH] global: utxos part 4 --- Cargo.lock | 2 + crates/brk_computer/Cargo.toml | 2 + crates/brk_computer/src/states/block.rs | 39 +- crates/brk_computer/src/states/cohort.rs | 3 +- crates/brk_computer/src/states/outputs.rs | 111 -- .../src/states/outputs/by_epoch.rs | 20 + .../src/states/outputs/by_from.rs | 20 + .../src/states/outputs/by_range.rs | 32 + .../src/states/outputs/by_size.rs | 38 + .../src/states/outputs/by_term.rs | 11 + .../src/states/outputs/by_type.rs | 94 ++ .../src/states/outputs/by_up_to.rs | 40 + .../src/states/outputs/by_value.rs | 37 + crates/brk_computer/src/states/outputs/mod.rs | 45 + crates/brk_computer/src/vecs/blocks.rs | 4 +- crates/brk_computer/src/vecs/constants.rs | 4 +- crates/brk_computer/src/vecs/fetched.rs | 4 +- .../src/vecs/grouped/from_dateindex.rs | 4 +- .../src/vecs/grouped/from_height.rs | 4 +- .../src/vecs/grouped/from_height_strict.rs | 4 +- .../src/vecs/grouped/from_txindex.rs | 4 +- .../src/vecs/grouped/ratio_from_dateindex.rs | 4 +- .../src/vecs/grouped/value_from_height.rs | 4 +- .../src/vecs/grouped/value_from_txindex.rs | 4 +- crates/brk_computer/src/vecs/market.rs | 6 +- crates/brk_computer/src/vecs/mining.rs | 4 +- crates/brk_computer/src/vecs/mod.rs | 26 +- crates/brk_computer/src/vecs/transactions.rs | 4 +- crates/brk_computer/src/vecs/utxos.rs | 1096 ++++++++++++++--- crates/brk_core/src/structs/outputtype.rs | 40 + crates/brk_core/src/structs/stored_u32.rs | 1 + crates/brk_core/src/structs/timestamp.rs | 20 +- crates/brk_vec/src/variants/eager.rs | 2 +- websites/kibo.money/scripts/main.js | 5 +- websites/kibo.money/scripts/options.js | 147 ++- .../kibo.money/scripts/vecid-to-indexes.js | 8 - 36 files changed, 1502 insertions(+), 391 deletions(-) delete mode 100644 crates/brk_computer/src/states/outputs.rs create mode 100644 crates/brk_computer/src/states/outputs/by_epoch.rs create mode 100644 crates/brk_computer/src/states/outputs/by_from.rs create mode 100644 crates/brk_computer/src/states/outputs/by_range.rs create mode 100644 crates/brk_computer/src/states/outputs/by_size.rs create mode 100644 crates/brk_computer/src/states/outputs/by_term.rs create mode 100644 crates/brk_computer/src/states/outputs/by_type.rs create mode 100644 crates/brk_computer/src/states/outputs/by_up_to.rs create mode 100644 crates/brk_computer/src/states/outputs/by_value.rs create mode 100644 crates/brk_computer/src/states/outputs/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 80d469c41..ca39f1ece 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -439,6 +439,8 @@ dependencies = [ "rayon", "serde", "serde_json", + "zerocopy", + "zerocopy-derive", ] [[package]] diff --git a/crates/brk_computer/Cargo.toml b/crates/brk_computer/Cargo.toml index bd6372684..c966bef9f 100644 --- a/crates/brk_computer/Cargo.toml +++ b/crates/brk_computer/Cargo.toml @@ -23,3 +23,5 @@ log = { workspace = true } rayon = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } +zerocopy = { workspace = true } +zerocopy-derive = { workspace = true } diff --git a/crates/brk_computer/src/states/block.rs b/crates/brk_computer/src/states/block.rs index 7920affd2..c6b3fc0d7 100644 --- a/crates/brk_computer/src/states/block.rs +++ b/crates/brk_computer/src/states/block.rs @@ -1,9 +1,40 @@ #![allow(unused)] -use brk_core::{Sats, StoredU32}; +use std::{ + iter::Sum, + ops::{Add, AddAssign, SubAssign}, +}; +use brk_core::{CheckedSub, Sats, StoredU32}; +use serde::Serialize; +use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout}; + +#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize)] pub struct BlockState { - utxos: StoredU32, - value: Sats, - unspendable: Sats, + pub utxos: usize, + pub value: Sats, +} + +impl Add for BlockState { + type Output = Self; + fn add(self, rhs: BlockState) -> Self::Output { + Self { + utxos: self.utxos + rhs.utxos, + value: self.value + rhs.value, + } + } +} + +impl AddAssign<&BlockState> for BlockState { + fn add_assign(&mut self, rhs: &BlockState) { + self.utxos += rhs.utxos; + self.value += rhs.value; + } +} + +impl SubAssign for BlockState { + fn sub_assign(&mut self, rhs: Self) { + self.utxos = self.utxos.checked_sub(rhs.utxos).unwrap(); + self.value = self.value.checked_sub(rhs.value).unwrap(); + } } diff --git a/crates/brk_computer/src/states/cohort.rs b/crates/brk_computer/src/states/cohort.rs index 801d12236..e0c195ec6 100644 --- a/crates/brk_computer/src/states/cohort.rs +++ b/crates/brk_computer/src/states/cohort.rs @@ -3,11 +3,10 @@ use brk_core::{Dollars, Sats, StoredUsize}; // Vecs ? probably -#[derive(Default)] +#[derive(Default, Clone)] pub struct CohortState { pub realized_cap: Dollars, pub supply: Sats, - pub unspendable_supply: Sats, pub utxo_count: StoredUsize, // pub price_to_amount: PriceToValue, save it not rounded in fjall } diff --git a/crates/brk_computer/src/states/outputs.rs b/crates/brk_computer/src/states/outputs.rs deleted file mode 100644 index c7078471a..000000000 --- a/crates/brk_computer/src/states/outputs.rs +++ /dev/null @@ -1,111 +0,0 @@ -#![allow(unused)] - -#[derive(Default, Clone)] -pub struct Outputs { - pub all: T, - // pub by_term: OutputsByTerm, - // pub by_up_to: OutputsByUpTo, - // pub by_from: OutputsByFrom, - // pub by_range: OutputsByRange, - // pub by_epoch: OutputsByEpoch, - // pub by_size: OutputsBySize, - // pub by_value: OutputsByValue, - // pub by_type: OutputsByType, // all but op-return -} - -#[derive(Default)] -pub struct OutputsByTerm { - pub short: T, - pub long: T, -} - -#[derive(Default)] -pub struct OutputsByUpTo { - 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 _5y: T, - pub _7y: T, - pub _10y: T, - pub _15y: T, -} - -#[derive(Default)] -pub struct OutputsByRange { - pub _1d_to_1w: T, - pub _1w_to_1m: T, - pub _1m_to_3m: T, - pub _3m_to_6m: T, - pub _6m_to_1y: T, - pub _1y_to_2y: T, - pub _2y_to_3y: T, - pub _3y_to_5y: T, - pub _5y_to_7y: T, - pub _7y_to_10y: T, - pub _10y_to_15y: T, -} - -#[derive(Default)] -pub struct OutputsByFrom { - pub _1y: T, - pub _2y: T, - pub _4y: T, - pub _10y: T, - pub _15y: T, -} - -#[derive(Default)] -pub struct OutputsByEpoch { - pub _1: T, - pub _2: T, - pub _3: T, - pub _4: T, - pub _5: T, -} - -#[derive(Default)] -pub struct OutputsBySize { - pub from_1_to_10: T, - pub from_10_to_100: T, - pub from_100_to_1_000: T, - pub from_1_000_to_10_000: T, - pub from_10000_to_100_000: T, - pub from_100_000_to_1_000_000: T, - pub from_1_000_000_to_10_000_000: T, - pub from_10_000_000_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, -} - -#[derive(Default)] -pub struct OutputsByValue { - pub up_to_1cent: T, - pub from_1c_to_10c: T, - pub from_10c_to_1d: T, - pub from_1d_to_10d: T, - pub from_10usd_to_100usd: T, - pub from_100usd_to_1_000usd: T, - pub from_1_000usd_to_10_000usd: T, - pub from_10_000usd_to_100_000usd: T, - pub from_100_000usd_to_1_000_000usd: T, - pub from_1_000_000usd_to_10_000_000usd: T, - pub from_10_000_000usd_to_100_000_000usd: T, - pub from_100_000_000usd_to_1_000_000_000usd: T, - pub from_1_000_000_000usd: T, - // ... -} - -// #[derive(Default)] -// pub struct OutputsByType {} diff --git a/crates/brk_computer/src/states/outputs/by_epoch.rs b/crates/brk_computer/src/states/outputs/by_epoch.rs new file mode 100644 index 000000000..5fc5d82b9 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_epoch.rs @@ -0,0 +1,20 @@ +#[derive(Default, Clone)] +pub struct OutputsByEpoch { + pub _1: T, + pub _2: T, + pub _3: T, + pub _4: T, + pub _5: T, +} + +impl OutputsByEpoch { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + vec![ + &mut self._1, + &mut self._2, + &mut self._3, + &mut self._4, + &mut self._5, + ] + } +} diff --git a/crates/brk_computer/src/states/outputs/by_from.rs b/crates/brk_computer/src/states/outputs/by_from.rs new file mode 100644 index 000000000..27ad15ee8 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_from.rs @@ -0,0 +1,20 @@ +#[derive(Default, Clone)] +pub struct OutputsByFrom { + pub _1y: T, + pub _2y: T, + pub _4y: T, + pub _10y: T, + pub _15y: T, +} + +impl OutputsByFrom { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + vec![ + &mut self._1y, + &mut self._2y, + &mut self._4y, + &mut self._10y, + &mut self._15y, + ] + } +} diff --git a/crates/brk_computer/src/states/outputs/by_range.rs b/crates/brk_computer/src/states/outputs/by_range.rs new file mode 100644 index 000000000..a96e6b850 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_range.rs @@ -0,0 +1,32 @@ +#[derive(Default, Clone)] +pub struct OutputsByRange { + pub _1d_to_1w: T, + pub _1w_to_1m: T, + pub _1m_to_3m: T, + pub _3m_to_6m: T, + pub _6m_to_1y: T, + pub _1y_to_2y: T, + pub _2y_to_3y: T, + pub _3y_to_5y: T, + pub _5y_to_7y: T, + pub _7y_to_10y: T, + pub _10y_to_15y: T, +} + +impl OutputsByRange { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + vec![ + &mut self._1d_to_1w, + &mut self._1w_to_1m, + &mut self._1m_to_3m, + &mut self._3m_to_6m, + &mut self._6m_to_1y, + &mut self._1y_to_2y, + &mut self._2y_to_3y, + &mut self._3y_to_5y, + &mut self._5y_to_7y, + &mut self._7y_to_10y, + &mut self._10y_to_15y, + ] + } +} diff --git a/crates/brk_computer/src/states/outputs/by_size.rs b/crates/brk_computer/src/states/outputs/by_size.rs new file mode 100644 index 000000000..6df9985f7 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_size.rs @@ -0,0 +1,38 @@ +#[derive(Default, Clone)] +pub struct OutputsBySize { + 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 OutputsBySize { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + vec![ + &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, + ] + } +} diff --git a/crates/brk_computer/src/states/outputs/by_term.rs b/crates/brk_computer/src/states/outputs/by_term.rs new file mode 100644 index 000000000..ad59dba99 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_term.rs @@ -0,0 +1,11 @@ +#[derive(Default, Clone)] +pub struct OutputsByTerm { + pub short: T, + pub long: T, +} + +impl OutputsByTerm { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + vec![&mut self.short, &mut self.long] + } +} diff --git a/crates/brk_computer/src/states/outputs/by_type.rs b/crates/brk_computer/src/states/outputs/by_type.rs new file mode 100644 index 000000000..9ec4c9d7a --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_type.rs @@ -0,0 +1,94 @@ +use brk_core::OutputType; + +#[derive(Default, Clone)] +pub struct OutputsByType { + pub p2pk65: T, + pub p2pk33: T, + pub p2pkh: T, + pub p2ms: T, + pub p2sh: T, + pub op_return: T, + pub p2wpkh: T, + pub p2wsh: T, + pub p2tr: T, + pub p2a: T, + pub empty: T, + pub unknown: T, +} + +impl OutputsByType { + pub fn get(&self, output_type: OutputType) -> &T { + match output_type { + OutputType::P2PK65 => &self.p2pk65, + OutputType::P2PK33 => &self.p2pk33, + OutputType::P2PKH => &self.p2pkh, + OutputType::P2MS => &self.p2ms, + OutputType::P2SH => &self.p2sh, + OutputType::OpReturn => &self.op_return, + OutputType::P2WPKH => &self.p2wpkh, + OutputType::P2WSH => &self.p2wsh, + OutputType::P2TR => &self.p2tr, + OutputType::P2A => &self.p2a, + OutputType::Empty => &self.empty, + OutputType::Unknown => &self.unknown, + } + } + + pub fn get_mut(&mut self, output_type: OutputType) -> &mut T { + match output_type { + OutputType::P2PK65 => &mut self.p2pk65, + OutputType::P2PK33 => &mut self.p2pk33, + OutputType::P2PKH => &mut self.p2pkh, + OutputType::P2MS => &mut self.p2ms, + OutputType::P2SH => &mut self.p2sh, + OutputType::OpReturn => &mut self.op_return, + OutputType::P2WPKH => &mut self.p2wpkh, + OutputType::P2WSH => &mut self.p2wsh, + OutputType::P2TR => &mut self.p2tr, + OutputType::P2A => &mut self.p2a, + OutputType::Empty => &mut self.empty, + OutputType::Unknown => &mut self.unknown, + } + } + + pub fn to_spendable_vec(&self) -> Vec<&T> { + OutputType::as_vec() + .into_iter() + .map(|t| (self.get(t))) + .collect::>() + } + + pub fn as_vec(&mut self) -> Vec<&T> { + vec![ + &self.p2pk65, + &self.p2pk33, + &self.p2pkh, + &self.p2ms, + &self.p2sh, + &self.op_return, + &self.p2wpkh, + &self.p2wsh, + &self.p2tr, + &self.p2a, + &self.empty, + &self.unknown, + ] + } + + pub fn as_mut_vec(&mut self) -> Vec<&mut T> { + vec![ + &mut self.p2pk65, + &mut self.p2pk33, + &mut self.p2pkh, + &mut self.p2ms, + &mut self.p2sh, + &mut self.op_return, + &mut self.p2wpkh, + &mut self.p2wsh, + &mut self.p2tr, + &mut self.p2a, + &mut self.empty, + &mut self.unknown, + ] + } +} diff --git a/crates/brk_computer/src/states/outputs/by_up_to.rs b/crates/brk_computer/src/states/outputs/by_up_to.rs new file mode 100644 index 000000000..23ff5c492 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_up_to.rs @@ -0,0 +1,40 @@ +#[derive(Default, Clone)] +pub struct OutputsByUpTo { + 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 _5y: T, + pub _7y: T, + pub _10y: T, + pub _15y: T, +} + +impl OutputsByUpTo { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + vec![ + &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._5y, + &mut self._7y, + &mut self._10y, + &mut self._15y, + ] + } +} diff --git a/crates/brk_computer/src/states/outputs/by_value.rs b/crates/brk_computer/src/states/outputs/by_value.rs new file mode 100644 index 000000000..f4bdd98c1 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/by_value.rs @@ -0,0 +1,37 @@ +#[derive(Default, Clone)] +pub struct OutputsByValue { + pub up_to_1cent: T, + pub from_1c_to_10c: T, + pub from_10c_to_1d: T, + pub from_1d_to_10d: T, + pub from_10usd_to_100usd: T, + pub from_100usd_to_1_000usd: T, + pub from_1_000usd_to_10_000usd: T, + pub from_10_000usd_to_100_000usd: T, + pub from_100_000usd_to_1_000_000usd: T, + pub from_1_000_000usd_to_10_000_000usd: T, + pub from_10_000_000usd_to_100_000_000usd: T, + pub from_100_000_000usd_to_1_000_000_000usd: T, + pub from_1_000_000_000usd: T, + // ... +} + +impl OutputsByValue { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + vec![ + &mut self.up_to_1cent, + &mut self.from_1c_to_10c, + &mut self.from_10c_to_1d, + &mut self.from_1d_to_10d, + &mut self.from_10usd_to_100usd, + &mut self.from_100usd_to_1_000usd, + &mut self.from_1_000usd_to_10_000usd, + &mut self.from_10_000usd_to_100_000usd, + &mut self.from_100_000usd_to_1_000_000usd, + &mut self.from_1_000_000usd_to_10_000_000usd, + &mut self.from_10_000_000usd_to_100_000_000usd, + &mut self.from_100_000_000usd_to_1_000_000_000usd, + &mut self.from_1_000_000_000usd, + ] + } +} diff --git a/crates/brk_computer/src/states/outputs/mod.rs b/crates/brk_computer/src/states/outputs/mod.rs new file mode 100644 index 000000000..29eda42d5 --- /dev/null +++ b/crates/brk_computer/src/states/outputs/mod.rs @@ -0,0 +1,45 @@ +#![allow(unused)] + +use brk_core::OutputType; + +use crate::vecs::utxos::Vecs_; + +mod by_epoch; +mod by_from; +mod by_range; +mod by_size; +mod by_term; +mod by_type; +mod by_up_to; +mod by_value; + +pub use by_epoch::*; +pub use by_from::*; +pub use by_range::*; +pub use by_size::*; +pub use by_term::*; +pub use by_type::*; +pub use by_up_to::*; +pub use by_value::*; + +#[derive(Default, Clone)] +pub struct Outputs { + pub all: T, + pub by_term: OutputsByTerm, + pub by_up_to: OutputsByUpTo, + pub by_from: OutputsByFrom, + pub by_range: OutputsByRange, + pub by_epoch: OutputsByEpoch, + pub by_size: OutputsBySize, + pub by_value: OutputsByValue, + pub by_type: OutputsByType, +} + +impl Outputs { + pub fn mut_flatten(&mut self) -> Vec<&mut T> { + [vec![&mut self.all], self.by_term.mut_flatten()] + .into_iter() + .flatten() + .collect::>() + } +} diff --git a/crates/brk_computer/src/vecs/blocks.rs b/crates/brk_computer/src/vecs/blocks.rs index 210c8e131..0fb043ed1 100644 --- a/crates/brk_computer/src/vecs/blocks.rs +++ b/crates/brk_computer/src/vecs/blocks.rs @@ -241,6 +241,8 @@ impl Vecs { self.indexes_to_block_vbytes.vecs(), self.indexes_to_block_weight.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/constants.rs b/crates/brk_computer/src/vecs/constants.rs index fdd870576..09f682f1f 100644 --- a/crates/brk_computer/src/vecs/constants.rs +++ b/crates/brk_computer/src/vecs/constants.rs @@ -144,6 +144,8 @@ impl Vecs { self._50.vecs(), self._100.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/fetched.rs b/crates/brk_computer/src/vecs/fetched.rs index 12042cb24..8b0fc2c6d 100644 --- a/crates/brk_computer/src/vecs/fetched.rs +++ b/crates/brk_computer/src/vecs/fetched.rs @@ -1089,6 +1089,8 @@ impl Vecs { self.chainindexes_to_low_in_sats.vecs(), self.chainindexes_to_open_in_sats.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/grouped/from_dateindex.rs b/crates/brk_computer/src/vecs/grouped/from_dateindex.rs index 383a887e3..9313ec870 100644 --- a/crates/brk_computer/src/vecs/grouped/from_dateindex.rs +++ b/crates/brk_computer/src/vecs/grouped/from_dateindex.rs @@ -155,6 +155,8 @@ where self.yearindex.vecs(), self.decadeindex.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/grouped/from_height.rs b/crates/brk_computer/src/vecs/grouped/from_height.rs index eb2591e53..299be642e 100644 --- a/crates/brk_computer/src/vecs/grouped/from_height.rs +++ b/crates/brk_computer/src/vecs/grouped/from_height.rs @@ -215,6 +215,8 @@ where // self.halvingepoch.vecs(), self.decadeindex.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/grouped/from_height_strict.rs b/crates/brk_computer/src/vecs/grouped/from_height_strict.rs index 19d7185f1..31c54e4f3 100644 --- a/crates/brk_computer/src/vecs/grouped/from_height_strict.rs +++ b/crates/brk_computer/src/vecs/grouped/from_height_strict.rs @@ -92,6 +92,8 @@ where self.difficultyepoch.vecs(), // self.halvingepoch.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/grouped/from_txindex.rs b/crates/brk_computer/src/vecs/grouped/from_txindex.rs index 4c53b9a2c..6d5a82d95 100644 --- a/crates/brk_computer/src/vecs/grouped/from_txindex.rs +++ b/crates/brk_computer/src/vecs/grouped/from_txindex.rs @@ -211,6 +211,8 @@ where // self.halvingepoch.vecs(), self.decadeindex.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs b/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs index 451472cbc..52c370365 100644 --- a/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs +++ b/crates/brk_computer/src/vecs/grouped/ratio_from_dateindex.rs @@ -896,6 +896,8 @@ impl ComputedRatioVecsFromDateIndex { self.ratio_m3sd_as_price.vecs(), self.ratio_zscore.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/grouped/value_from_height.rs b/crates/brk_computer/src/vecs/grouped/value_from_height.rs index d4efab6e7..a0ed0ce16 100644 --- a/crates/brk_computer/src/vecs/grouped/value_from_height.rs +++ b/crates/brk_computer/src/vecs/grouped/value_from_height.rs @@ -165,6 +165,8 @@ impl ComputedValueVecsFromHeight { self.bitcoin.vecs(), self.dollars.as_ref().map_or(vec![], |v| v.vecs()), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs b/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs index bd84aee49..5ccaea444 100644 --- a/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs +++ b/crates/brk_computer/src/vecs/grouped/value_from_txindex.rs @@ -221,6 +221,8 @@ impl ComputedValueVecsFromTxindex { self.bitcoin.vecs(), self.dollars.as_ref().map_or(vec![], |v| v.vecs()), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/market.rs b/crates/brk_computer/src/vecs/market.rs index bc2d539df..6a4c31faf 100644 --- a/crates/brk_computer/src/vecs/market.rs +++ b/crates/brk_computer/src/vecs/market.rs @@ -13,7 +13,7 @@ use super::{ indexes, transactions, }; -const VERSION: Version = Version::new(0); +const VERSION: Version = Version::ZERO; #[derive(Clone)] pub struct Vecs { @@ -1774,6 +1774,8 @@ impl Vecs { self.dca_class_2016_returns.vecs(), self.dca_class_2015_returns.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/mining.rs b/crates/brk_computer/src/vecs/mining.rs index 87fa8bb83..15766d77f 100644 --- a/crates/brk_computer/src/vecs/mining.rs +++ b/crates/brk_computer/src/vecs/mining.rs @@ -123,6 +123,8 @@ impl Vecs { self.indexes_to_difficultyepoch.vecs(), self.indexes_to_halvingepoch.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/mod.rs b/crates/brk_computer/src/vecs/mod.rs index 4c57215ab..7bbbb4253 100644 --- a/crates/brk_computer/src/vecs/mod.rs +++ b/crates/brk_computer/src/vecs/mod.rs @@ -25,7 +25,7 @@ pub struct Vecs { pub mining: mining::Vecs, pub market: market::Vecs, pub transactions: transactions::Vecs, - pub utxos: utxos::Vecs, + // pub utxos: utxos::Vecs, pub fetched: Option, } @@ -49,7 +49,7 @@ impl Vecs { mining: mining::Vecs::forced_import(path, computation, compressed)?, constants: constants::Vecs::forced_import(path, computation, compressed)?, market: market::Vecs::forced_import(path, computation, compressed)?, - utxos: utxos::Vecs::forced_import(path, computation, compressed, fetched.as_ref())?, + // utxos: utxos::Vecs::forced_import(path, computation, compressed, fetched.as_ref())?, transactions: transactions::Vecs::forced_import( path, indexer, @@ -110,14 +110,14 @@ impl Vecs { )?; } - self.utxos.compute( - indexer, - &self.indexes, - &self.transactions, - self.fetched.as_ref(), - &starting_indexes, - exit, - )?; + // self.utxos.compute( + // indexer, + // &self.indexes, + // &self.transactions, + // self.fetched.as_ref(), + // &starting_indexes, + // exit, + // )?; Ok(()) } @@ -130,9 +130,11 @@ impl Vecs { self.mining.vecs(), self.market.vecs(), self.transactions.vecs(), - self.utxos.vecs(), + // self.utxos.vecs(), self.fetched.as_ref().map_or(vec![], |v| v.vecs()), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/transactions.rs b/crates/brk_computer/src/vecs/transactions.rs index 8ded154f8..bbbac0228 100644 --- a/crates/brk_computer/src/vecs/transactions.rs +++ b/crates/brk_computer/src/vecs/transactions.rs @@ -1169,6 +1169,8 @@ impl Vecs { self.indexes_to_exact_utxo_count.vecs(), self.indexes_to_unclaimed_rewards.vecs(), ] - .concat() + .into_iter() + .flatten() + .collect::>() } } diff --git a/crates/brk_computer/src/vecs/utxos.rs b/crates/brk_computer/src/vecs/utxos.rs index 861271554..94f3deaab 100644 --- a/crates/brk_computer/src/vecs/utxos.rs +++ b/crates/brk_computer/src/vecs/utxos.rs @@ -1,4 +1,4 @@ -use std::{collections::BTreeMap, fs, path::Path, thread}; +use std::{cmp::Ordering, collections::BTreeMap, fs, mem, path::Path, thread}; use brk_core::{ Bitcoin, CheckedSub, Dollars, Height, InputIndex, OutputIndex, OutputType, Sats, StoredUsize, @@ -6,13 +6,17 @@ use brk_core::{ use brk_exit::Exit; use brk_indexer::Indexer; use brk_vec::{ - AnyCollectableVec, AnyVec, BaseVecIterator, Compressed, Computation, EagerVec, StoredIndex, - VecIterator, Version, + AnyCollectableVec, AnyVec, BaseVecIterator, CollectableVec, Compressed, Computation, EagerVec, + GenericStoredVec, IndexedVec, Result, StoredIndex, StoredVec, VecIterator, Version, }; use derive_deref::{Deref, DerefMut}; use rayon::prelude::*; -use crate::states::{CohortState, Outputs, OutputsByTerm, RealizedState, ReceivedState, SentState}; +use crate::states::{ + BlockState, CohortState, Outputs, OutputsByEpoch, OutputsByFrom, OutputsByRange, OutputsBySize, + OutputsByTerm, OutputsByType, OutputsByUpTo, OutputsByValue, RealizedState, ReceivedState, + SentState, +}; use super::{ Indexes, fetched, @@ -22,8 +26,17 @@ use super::{ const VERSION: Version = Version::new(3); -#[derive(Clone, Deref, DerefMut)] -pub struct Vecs(Outputs); +#[derive(Clone)] +pub struct Vecs { + chain_state: Vec, + saved_chain_state: StoredVec, + + // unspendable + // cointime ? + pub height_to_unspendable_supply: EagerVec, + pub indexes_to_unspendable_supply: ComputedValueVecsFromHeight, + utxos_vecs: Outputs, +} impl Vecs { pub fn forced_import( @@ -32,13 +45,597 @@ impl Vecs { compressed: Compressed, fetched: Option<&fetched::Vecs>, ) -> color_eyre::Result { - Ok(Self(Outputs { - all: Vecs_::forced_import(path, None, _computation, compressed, fetched)?, - // by_term: OutputsByTerm { - // short: Vecs_::forced_import(path, Some("sth"), _computation, compressed, fetched)?, - // long: Vecs_::forced_import(path, Some("lth"), _computation, compressed, fetched)?, - // }, - })) + let compute_dollars = fetched.is_some(); + + let mut states_path = path.to_owned(); + states_path.pop(); + states_path = states_path.join("states"); + + Ok(Self { + chain_state: vec![], + saved_chain_state: StoredVec::forced_import( + &states_path, + "chain", + Version::ZERO, + Compressed::NO, + )?, + + height_to_unspendable_supply: EagerVec::forced_import( + path, + "unspendable_supply", + VERSION + Version::ZERO, + compressed, + )?, + indexes_to_unspendable_supply: ComputedValueVecsFromHeight::forced_import( + path, + "unspendable_supply", + false, + VERSION + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default().add_last(), + compute_dollars, + )?, + utxos_vecs: { + Outputs { + all: Vecs_::forced_import(path, None, _computation, compressed, fetched)?, + by_term: OutputsByTerm { + short: Vecs_::forced_import( + path, + Some("sth"), + _computation, + compressed, + fetched, + )?, + long: Vecs_::forced_import( + path, + Some("lth"), + _computation, + compressed, + fetched, + )?, + }, + by_up_to: OutputsByUpTo { + _1d: Vecs_::forced_import( + path, + Some("up_to_1d"), + _computation, + compressed, + fetched, + )?, + _1w: Vecs_::forced_import( + path, + Some("up_to_1w"), + _computation, + compressed, + fetched, + )?, + _1m: Vecs_::forced_import( + path, + Some("up_to_1m"), + _computation, + compressed, + fetched, + )?, + _2m: Vecs_::forced_import( + path, + Some("up_to_2m"), + _computation, + compressed, + fetched, + )?, + _3m: Vecs_::forced_import( + path, + Some("up_to_3m"), + _computation, + compressed, + fetched, + )?, + _4m: Vecs_::forced_import( + path, + Some("up_to_4m"), + _computation, + compressed, + fetched, + )?, + _5m: Vecs_::forced_import( + path, + Some("up_to_5m"), + _computation, + compressed, + fetched, + )?, + _6m: Vecs_::forced_import( + path, + Some("up_to_6m"), + _computation, + compressed, + fetched, + )?, + _1y: Vecs_::forced_import( + path, + Some("up_to_1y"), + _computation, + compressed, + fetched, + )?, + _2y: Vecs_::forced_import( + path, + Some("up_to_2y"), + _computation, + compressed, + fetched, + )?, + _3y: Vecs_::forced_import( + path, + Some("up_to_3y"), + _computation, + compressed, + fetched, + )?, + _5y: Vecs_::forced_import( + path, + Some("up_to_5y"), + _computation, + compressed, + fetched, + )?, + _7y: Vecs_::forced_import( + path, + Some("up_to_7y"), + _computation, + compressed, + fetched, + )?, + _10y: Vecs_::forced_import( + path, + Some("up_to_10y"), + _computation, + compressed, + fetched, + )?, + _15y: Vecs_::forced_import( + path, + Some("up_to_15y"), + _computation, + compressed, + fetched, + )?, + }, + by_from: OutputsByFrom { + _1y: Vecs_::forced_import( + path, + Some("from_1y"), + _computation, + compressed, + fetched, + )?, + _2y: Vecs_::forced_import( + path, + Some("from_2y"), + _computation, + compressed, + fetched, + )?, + _4y: Vecs_::forced_import( + path, + Some("from_4y"), + _computation, + compressed, + fetched, + )?, + _10y: Vecs_::forced_import( + path, + Some("from_10y"), + _computation, + compressed, + fetched, + )?, + _15y: Vecs_::forced_import( + path, + Some("from_15y"), + _computation, + compressed, + fetched, + )?, + }, + by_range: OutputsByRange { + _1d_to_1w: Vecs_::forced_import( + path, + Some("from_1d_to_1w"), + _computation, + compressed, + fetched, + )?, + _1w_to_1m: Vecs_::forced_import( + path, + Some("from_1w_to_1m"), + _computation, + compressed, + fetched, + )?, + _1m_to_3m: Vecs_::forced_import( + path, + Some("from_1m_to_3m"), + _computation, + compressed, + fetched, + )?, + _3m_to_6m: Vecs_::forced_import( + path, + Some("from_3m_to_6m"), + _computation, + compressed, + fetched, + )?, + _6m_to_1y: Vecs_::forced_import( + path, + Some("from_6m_to_1y"), + _computation, + compressed, + fetched, + )?, + _1y_to_2y: Vecs_::forced_import( + path, + Some("from_1y_to_2y"), + _computation, + compressed, + fetched, + )?, + _2y_to_3y: Vecs_::forced_import( + path, + Some("from_2y_to_3y"), + _computation, + compressed, + fetched, + )?, + _3y_to_5y: Vecs_::forced_import( + path, + Some("from_3y_to_5y"), + _computation, + compressed, + fetched, + )?, + _5y_to_7y: Vecs_::forced_import( + path, + Some("from_5y_to_7y"), + _computation, + compressed, + fetched, + )?, + _7y_to_10y: Vecs_::forced_import( + path, + Some("from_7y_to_10y"), + _computation, + compressed, + fetched, + )?, + _10y_to_15y: Vecs_::forced_import( + path, + Some("from_10y_to_15y"), + _computation, + compressed, + fetched, + )?, + }, + by_epoch: OutputsByEpoch { + _1: Vecs_::forced_import( + path, + Some("epoch_1"), + _computation, + compressed, + fetched, + )?, + _2: Vecs_::forced_import( + path, + Some("epoch_2"), + _computation, + compressed, + fetched, + )?, + _3: Vecs_::forced_import( + path, + Some("epoch_3"), + _computation, + compressed, + fetched, + )?, + _4: Vecs_::forced_import( + path, + Some("epoch_4"), + _computation, + compressed, + fetched, + )?, + _5: Vecs_::forced_import( + path, + Some("epoch_5"), + _computation, + compressed, + fetched, + )?, + }, + by_size: OutputsBySize { + from_1sat_to_10sats: Vecs_::forced_import( + path, + Some("from_1sat_to_10sats"), + _computation, + compressed, + fetched, + )?, + from_10sats_to_100sats: Vecs_::forced_import( + path, + Some("from_10sats_to_100sats"), + _computation, + compressed, + fetched, + )?, + from_100sats_to_1_000sats: Vecs_::forced_import( + path, + Some("from_100sats_to_1_000sats"), + _computation, + compressed, + fetched, + )?, + from_1_000sats_to_10_000sats: Vecs_::forced_import( + path, + Some("from_1_000sats_to_10_000sats"), + _computation, + compressed, + fetched, + )?, + from_10_000sats_to_100_000sats: Vecs_::forced_import( + path, + Some("from_10_000sats_to_100_000sats"), + _computation, + compressed, + fetched, + )?, + from_100_000sats_to_1_000_000sats: Vecs_::forced_import( + path, + Some("from_100_000sats_to_1_000_000sats"), + _computation, + compressed, + fetched, + )?, + from_1_000_000sats_to_10_000_000sats: Vecs_::forced_import( + path, + Some("from_1_000_000sats_to_10_000_000sats"), + _computation, + compressed, + fetched, + )?, + from_10_000_000sats_to_1btc: Vecs_::forced_import( + path, + Some("from_10_000_000sats_to_1btc"), + _computation, + compressed, + fetched, + )?, + from_1btc_to_10btc: Vecs_::forced_import( + path, + Some("from_1btc_to_10btc"), + _computation, + compressed, + fetched, + )?, + from_10btc_to_100btc: Vecs_::forced_import( + path, + Some("from_10btc_to_100btc"), + _computation, + compressed, + fetched, + )?, + from_100btc_to_1_000btc: Vecs_::forced_import( + path, + Some("from_100btc_to_1_000btc"), + _computation, + compressed, + fetched, + )?, + from_1_000btc_to_10_000btc: Vecs_::forced_import( + path, + Some("from_1_000btc_to_10_000btc"), + _computation, + compressed, + fetched, + )?, + from_10_000btc_to_100_000btc: Vecs_::forced_import( + path, + Some("from_10_000btc_to_100_000btc"), + _computation, + compressed, + fetched, + )?, + from_100_000btc: Vecs_::forced_import( + path, + Some("from_100_000btc"), + _computation, + compressed, + fetched, + )?, + }, + by_value: OutputsByValue { + up_to_1cent: Vecs_::forced_import( + path, + Some("up_to_1cent"), + _computation, + compressed, + fetched, + )?, + from_1c_to_10c: Vecs_::forced_import( + path, + Some("from_1c_to_10c"), + _computation, + compressed, + fetched, + )?, + from_10c_to_1d: Vecs_::forced_import( + path, + Some("from_10c_to_1d"), + _computation, + compressed, + fetched, + )?, + from_1d_to_10d: Vecs_::forced_import( + path, + Some("from_1d_to_10d"), + _computation, + compressed, + fetched, + )?, + from_10usd_to_100usd: Vecs_::forced_import( + path, + Some("from_10usd_to_100usd"), + _computation, + compressed, + fetched, + )?, + from_100usd_to_1_000usd: Vecs_::forced_import( + path, + Some("from_100usd_to_1_000usd"), + _computation, + compressed, + fetched, + )?, + from_1_000usd_to_10_000usd: Vecs_::forced_import( + path, + Some("from_1_000usd_to_10_000usd"), + _computation, + compressed, + fetched, + )?, + from_10_000usd_to_100_000usd: Vecs_::forced_import( + path, + Some("from_10_000usd_to_100_000usd"), + _computation, + compressed, + fetched, + )?, + from_100_000usd_to_1_000_000usd: Vecs_::forced_import( + path, + Some("from_100_000usd_to_1_000_000usd"), + _computation, + compressed, + fetched, + )?, + from_1_000_000usd_to_10_000_000usd: Vecs_::forced_import( + path, + Some("from_1_000_000usd_to_10_000_000usd"), + _computation, + compressed, + fetched, + )?, + from_10_000_000usd_to_100_000_000usd: Vecs_::forced_import( + path, + Some("from_10_000_000usd_to_100_000_000usd"), + _computation, + compressed, + fetched, + )?, + from_100_000_000usd_to_1_000_000_000usd: Vecs_::forced_import( + path, + Some("from_100_000_000usd_to_1_000_000_000usd"), + _computation, + compressed, + fetched, + )?, + from_1_000_000_000usd: Vecs_::forced_import( + path, + Some("from_1_000_000_000usd"), + _computation, + compressed, + fetched, + )?, + }, + by_type: OutputsByType { + p2pk65: Vecs_::forced_import( + path, + Some("p2pk65"), + _computation, + compressed, + fetched, + )?, + p2pk33: Vecs_::forced_import( + path, + Some("p2pk33"), + _computation, + compressed, + fetched, + )?, + p2pkh: Vecs_::forced_import( + path, + Some("p2pkh"), + _computation, + compressed, + fetched, + )?, + p2ms: Vecs_::forced_import( + path, + Some("p2ms"), + _computation, + compressed, + fetched, + )?, + p2sh: Vecs_::forced_import( + path, + Some("p2sh"), + _computation, + compressed, + fetched, + )?, + op_return: Vecs_::forced_import( + path, + Some("op_return"), + _computation, + compressed, + fetched, + )?, + p2wpkh: Vecs_::forced_import( + path, + Some("p2wpkh"), + _computation, + compressed, + fetched, + )?, + p2wsh: Vecs_::forced_import( + path, + Some("p2wsh"), + _computation, + compressed, + fetched, + )?, + p2tr: Vecs_::forced_import( + path, + Some("p2tr"), + _computation, + compressed, + fetched, + )?, + p2a: Vecs_::forced_import( + path, + Some("p2a"), + _computation, + compressed, + fetched, + )?, + empty: Vecs_::forced_import( + path, + Some("empty"), + _computation, + compressed, + fetched, + )?, + unknown: Vecs_::forced_import( + path, + Some("unknown"), + _computation, + compressed, + fetched, + )?, + }, + } + }, + }) } pub fn compute( @@ -72,12 +669,6 @@ impl Vecs { let height_to_close = &fetched .as_ref() .map(|fetched| &fetched.chainindexes_to_close.height); - let height_to_opreturn_count = &transactions - .indexes_to_opreturn_count - .height - .as_ref() - .unwrap() - .as_ref(); let mut height_to_first_outputindex_iter = height_to_first_outputindex.into_iter(); let mut height_to_first_inputindex_iter = height_to_first_inputindex.into_iter(); @@ -89,11 +680,13 @@ impl Vecs { let mut txindex_to_height_iter = txindex_to_height.into_iter(); let mut outputindex_to_txindex_iter = outputindex_to_txindex.into_iter(); let mut height_to_close_iter = height_to_close.as_ref().map(|v| v.into_iter()); - let mut height_to_opreturn_count_iter = height_to_opreturn_count.into_iter(); let mut outputindex_to_outputtype_iter = outputindex_to_outputtype.into_iter(); + let mut outputindex_to_outputtype_iter_2 = outputindex_to_outputtype.into_iter(); let mut height_to_unclaimed_rewards_iter = height_to_unclaimed_rewards.into_iter(); let mut height_to_timestamp_fixed_iter = height_to_timestamp_fixed.into_iter(); + let mut flat_vecs_ = self.utxos_vecs.mut_flatten(); + let base_version = Version::ZERO + height_to_first_outputindex.version() + height_to_first_inputindex.version() @@ -104,70 +697,60 @@ impl Vecs { + outputindex_to_value.version() + txindex_to_height.version() + outputindex_to_txindex.version() - + height_to_opreturn_count.version() + outputindex_to_outputtype.version() + height_to_unclaimed_rewards.version() + height_to_close .as_ref() .map_or(Version::ZERO, |v| v.version()); - let mut height_to_realized_cap = self.0.all.height_to_realized_cap.as_mut(); - let height_to_supply = &mut self.0.all.height_to_supply; - let height_to_unspendable_supply = &mut self.0.all.height_to_unspendable_supply; - let height_to_utxo_count = &mut self.0.all.height_to_utxo_count; - - height_to_supply.validate_computed_version_or_reset_file( - base_version + height_to_supply.inner_version(), - )?; - height_to_unspendable_supply.validate_computed_version_or_reset_file( - base_version + height_to_unspendable_supply.inner_version(), - )?; - height_to_utxo_count.validate_computed_version_or_reset_file( - base_version + height_to_utxo_count.inner_version(), - )?; - if let Some(height_to_realized_cap) = height_to_realized_cap.as_mut() { - height_to_realized_cap.validate_computed_version_or_reset_file( - base_version + height_to_realized_cap.inner_version(), + flat_vecs_ + .iter_mut() + .try_for_each(|v| v.validate_computed_versions(base_version))?; + self.height_to_unspendable_supply + .validate_computed_version_or_reset_file( + base_version + self.height_to_unspendable_supply.inner_version(), )?; - } - let starting_height = [ - height_to_supply.len(), - height_to_unspendable_supply.len(), - height_to_utxo_count.len(), - height_to_realized_cap - .as_ref() - .map_or(usize::MAX, |v| v.len()), - ] - .into_iter() - .map(Height::from) - .min() - .unwrap() - .min(starting_indexes.height); + let chain_state_starting_height = Height::from(self.saved_chain_state.len()); - let mut state = CohortState::default(); + let starting_height = flat_vecs_ + .iter_mut() + .map(|v| v.init(starting_indexes)) + .min() + .unwrap_or_default() + .min(chain_state_starting_height); - if let Some(prev_height) = starting_height.checked_sub(Height::new(1)) { - state.supply = height_to_supply.into_iter().unwrap_get_inner(prev_height); - state.unspendable_supply = height_to_unspendable_supply - .into_iter() - .unwrap_get_inner(prev_height); - state.utxo_count = height_to_utxo_count - .into_iter() - .unwrap_get_inner(prev_height); - if let Some(height_to_realized_cap) = height_to_realized_cap.as_mut() { - state.realized_cap = height_to_realized_cap - .into_iter() - .unwrap_get_inner(prev_height); + // self.state.unspendable_supply = self + // .height_to_unspendable_supply + // .into_iter() + // .unwrap_get_inner(prev_height); + // + // / self.state.unspendable_supply = self + // .height_to_unspendable_supply + // . + // starting_height + + match starting_height.cmp(&chain_state_starting_height) { + Ordering::Greater => unreachable!(), + Ordering::Equal => { + self.chain_state = self.saved_chain_state.collect_range(None, None)?; + } + Ordering::Less => { + todo!("rollback instead"); + // self.chain_state = vec![]; + // starting_height = Height::ZERO; } } + let mut height = Height::ZERO; (starting_height.unwrap_to_usize()..height_to_first_outputindex_iter.len()) .map(Height::from) - .try_for_each(|height| -> color_eyre::Result<()> { - let sent_state = SentState::default(); - let received_state = ReceivedState::default(); - let realized_state = RealizedState::default(); + .try_for_each(|_height| -> color_eyre::Result<()> { + height = _height; + + // let sent_state = SentState::default(); + // let received_state = ReceivedState::default(); + // let realized_state = RealizedState::default(); let first_outputindex = height_to_first_outputindex_iter .unwrap_get_inner(height) @@ -177,15 +760,16 @@ impl Vecs { .unwrap_to_usize(); 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 opreturn_count = height_to_opreturn_count_iter.unwrap_get_inner(height); + // let opreturn_count = height_to_opreturn_count_iter.unwrap_get_inner(height); - let (sent_sats_price_tuple, (mut received_spendable, mut received_unspendable)) = + let ((height_to_sent_data, block_state_to_subtract), mut received) = thread::scope(|s| { - // Skip coinbase - let sent_sats_price_tuple = s.spawn(|| { + let sent = s.spawn(|| { let mut txindex_to_height = BTreeMap::new(); - let mut height_to_timestamp_price_sats = BTreeMap::new(); + let mut height_to_sent_data = BTreeMap::new(); + let mut block_state_to_subtract = BlockState::default(); + // Skip coinbase (first_inputindex + 1..first_inputindex + *input_count) .map(InputIndex::from) .map(|inputindex| { @@ -195,71 +779,93 @@ impl Vecs { let value = outputindex_to_value_iter.unwrap_get_inner(outputindex); + let _type = outputindex_to_outputtype_iter + .unwrap_get_inner(outputindex); + let txindex = outputindex_to_txindex_iter.unwrap_get_inner(outputindex); - let height = + let input_height = *txindex_to_height.entry(txindex).or_insert_with(|| { txindex_to_height_iter.unwrap_get_inner(txindex) }); - let entry = height_to_timestamp_price_sats - .entry(height) + match input_height.cmp(&height) { + Ordering::Equal => { + block_state_to_subtract.utxos += 1; + block_state_to_subtract.value += value; + } + Ordering::Greater => unreachable!(), + Ordering::Less => { + let block_state = self + .chain_state + .get_mut(input_height.unwrap_to_usize()) + .unwrap(); + block_state.utxos -= 1; + block_state.value -= value; + } + } + + let input_data = height_to_sent_data + .entry(input_height) .or_insert_with(|| { let timestamp = height_to_timestamp_fixed_iter - .unwrap_get_inner(height); + .unwrap_get_inner(input_height); if let Some(height_to_close_iter) = height_to_close_iter.as_mut() { - let dollars = - *height_to_close_iter.unwrap_get_inner(height); + let dollars = *height_to_close_iter + .unwrap_get_inner(input_height); - (timestamp, dollars, Sats::ZERO) + (timestamp, dollars, Sats::ZERO, _type) } else { - (timestamp, Dollars::ZERO, Sats::ZERO) + (timestamp, Dollars::ZERO, Sats::ZERO, _type) } }); - entry.2 += value; + input_data.2 += value; }); - height_to_timestamp_price_sats + (height_to_sent_data, block_state_to_subtract) }); let received = s.spawn(|| { - let mut spendable = Sats::ZERO; - let mut unspendable = Sats::ZERO; + let mut by_type: OutputsByType = OutputsByType::default(); + (first_outputindex..first_outputindex + *output_count) .map(OutputIndex::from) .for_each(|outputindex| { let value = outputindex_to_value_iter_2.unwrap_get_inner(outputindex); - let outputtype = outputindex_to_outputtype_iter + let outputtype = outputindex_to_outputtype_iter_2 .unwrap_get_inner(outputindex); - if outputtype == OutputType::OpReturn - || outputtype == OutputType::Empty - || outputtype == OutputType::Unknown - { - unspendable += value - } else { - spendable += value - } + by_type.get_mut(outputtype).value += value; + by_type.get_mut(outputtype).utxos += 1; }); - (spendable, unspendable) + + by_type }); - ( - sent_sats_price_tuple.join().unwrap(), - received.join().unwrap(), - ) + (sent.join().unwrap(), received.join().unwrap()) }); - let (sent, realized_cap_destroyed) = sent_sats_price_tuple + // Compute then push current block state + let mut block_state = BlockState::default(); + received + .to_spendable_vec() + .into_iter() + .for_each(|spendable_block_state| { + block_state += spendable_block_state; + }); + block_state -= block_state_to_subtract; + self.chain_state.push(block_state); + + let (sent, realized_cap_destroyed) = height_to_sent_data .par_iter() - .map(|(_, (_, dollars, sats))| { + .map(|(_, (_, dollars, sats, _))| { let dollars = *dollars; let sats = *sats; (sats, dollars * Bitcoin::from(sats)) @@ -269,107 +875,117 @@ impl Vecs { |acc, (sats, dollars)| (acc.0 + sats, acc.1 + dollars), ); - let utxos_created = *output_count - *opreturn_count; + let utxos_created = *output_count - received.op_return.utxos; + + let mut received_unspendable = OutputType::as_vec() + .into_iter() + .filter(|t| t.is_unspendable()) + .map(|t| received.get_mut(t).value) + .sum::() + + height_to_unclaimed_rewards_iter.unwrap_get_inner(height); // Three invalid coinbases which all have 1 output let utxos_destroyed = if height == Height::new(0) || height == Height::new(91_842) || height == Height::new(91_880) { - received_spendable -= Sats::FIFTY_BTC; + // They're all p2pk65 + received.p2pk65.utxos -= 1; + received.p2pk65.value -= Sats::FIFTY_BTC; received_unspendable += Sats::FIFTY_BTC; *input_count } else { *input_count - 1 }; - received_unspendable += height_to_unclaimed_rewards_iter.unwrap_get_inner(height); + // state.supply -= sent; - state.supply -= sent; + // state.supply += received_spendable; + // state.unspendable_supply += received_unspendable; - state.supply += received_spendable; - state.unspendable_supply += received_unspendable; + // *state.utxo_count += utxos_created; + // *state.utxo_count -= utxos_destroyed; - *state.utxo_count += utxos_created; - *state.utxo_count -= utxos_destroyed; + // if let Some(height_to_close_iter) = height_to_close_iter.as_mut() { + // let received = received_spendable + received_unspendable; + // let price = *height_to_close_iter.unwrap_get_inner(height); + // let realized_cap_created = price * Bitcoin::from(received); + // state.realized_cap = (state.realized_cap + realized_cap_created) + // .checked_sub(realized_cap_destroyed) + // .unwrap(); + // } - if let Some(height_to_close_iter) = height_to_close_iter.as_mut() { - let received = received_spendable + received_unspendable; - let price = *height_to_close_iter.unwrap_get_inner(height); - let realized_cap_created = price * Bitcoin::from(received); - state.realized_cap = (state.realized_cap + realized_cap_created) - .checked_sub(realized_cap_destroyed) - .unwrap(); - } + self.utxos_vecs + .mut_flatten() + .iter_mut() + .try_for_each(|v| v.forced_pushed_at(height, exit))?; - height_to_supply.forced_push_at(height, state.supply, exit)?; - height_to_unspendable_supply.forced_push_at( - height, - state.unspendable_supply, - exit, - )?; - height_to_utxo_count.forced_push_at(height, state.utxo_count, exit)?; - if let Some(height_to_realized_cap) = height_to_realized_cap.as_mut() { - height_to_realized_cap.forced_push_at(height, state.realized_cap, exit)?; - } + // // self.height_to_unspendable_supply.forced_push_at( + // height, + // self.state.unspendable_supply, + // exit, + // )?; Ok(()) })?; - height_to_supply.safe_flush(exit)?; - height_to_unspendable_supply.safe_flush(exit)?; - height_to_utxo_count.safe_flush(exit)?; - if let Some(height_to_realized_cap) = height_to_realized_cap.as_mut() { - height_to_realized_cap.safe_flush(exit)?; - } + exit.block(); - self.0.all.indexes_to_supply.compute_rest( + let mut flat_vecs_ = self.utxos_vecs.mut_flatten(); + + // Flush rest of values + flat_vecs_ + .iter_mut() + .try_for_each(|v| v.safe_flush_height_vecs(exit))?; + self.height_to_unspendable_supply.safe_flush(exit)?; + + // Compute other vecs from height vecs + flat_vecs_ + .iter_mut() + .try_for_each(|v| v.compute_rest(indexer, indexes, fetched, starting_indexes, exit))?; + self.indexes_to_unspendable_supply.compute_rest( indexer, indexes, fetched, starting_indexes, exit, - Some(&self.0.all.height_to_supply), + Some(&self.height_to_unspendable_supply), )?; - self.0.all.indexes_to_unspendable_supply.compute_rest( - indexer, - indexes, - fetched, - starting_indexes, - exit, - Some(&self.0.all.height_to_unspendable_supply), - )?; - self.0.all.indexes_to_utxo_count.compute_rest( - indexes, - starting_indexes, - exit, - Some(&self.0.all.height_to_utxo_count), - )?; - if let Some(indexes_to_realized_cap) = self.0.all.indexes_to_realized_cap.as_mut() { - indexes_to_realized_cap.compute_rest( - indexes, - starting_indexes, - exit, - Some(self.0.all.height_to_realized_cap.as_ref().unwrap()), - )?; - } + + // Save chain state + self.saved_chain_state.truncate_if_needed(Height::ZERO)?; + mem::take(&mut self.chain_state) + .into_iter() + .for_each(|block_state| { + self.saved_chain_state.push(block_state); + }); + self.saved_chain_state.flush()?; + + exit.release(); Ok(()) } pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> { - [self.all.vecs()].concat() + [ + self.utxos_vecs.all.vecs(), + self.indexes_to_unspendable_supply.vecs(), + vec![&self.height_to_unspendable_supply], + ] + .into_iter() + .flatten() + .collect::>() } } -#[derive(Clone)] pub struct Vecs_ { + starting_height: Height, + state: CohortState, + pub height_to_realized_cap: Option>, pub indexes_to_realized_cap: Option>, pub height_to_supply: EagerVec, pub indexes_to_supply: ComputedValueVecsFromHeight, - pub height_to_unspendable_supply: EagerVec, - pub indexes_to_unspendable_supply: ComputedValueVecsFromHeight, pub height_to_utxo_count: EagerVec, pub indexes_to_utxo_count: ComputedVecsFromHeight, } @@ -391,6 +1007,9 @@ impl Vecs_ { let suffix = |s: &str| cohort_name.map_or(s.to_string(), |name| format!("{name}_{s}")); Ok(Self { + starting_height: Height::ZERO, + state: CohortState::default(), + height_to_realized_cap: compute_dollars.then(|| { EagerVec::forced_import( path, @@ -426,25 +1045,10 @@ impl Vecs_ { StorableVecGeneatorOptions::default().add_last(), compute_dollars, )?, - height_to_unspendable_supply: EagerVec::forced_import( - path, - &suffix("unspendable_supply"), - VERSION + Version::ZERO, - compressed, - )?, - indexes_to_unspendable_supply: ComputedValueVecsFromHeight::forced_import( - path, - &suffix("unspendable_supply"), - false, - VERSION + Version::ZERO, - compressed, - StorableVecGeneatorOptions::default().add_last(), - compute_dollars, - )?, height_to_utxo_count: EagerVec::forced_import( path, &suffix("utxo_count"), - VERSION + Version::new(111), + VERSION + Version::ZERO, compressed, )?, indexes_to_utxo_count: ComputedVecsFromHeight::forced_import( @@ -458,23 +1062,153 @@ impl Vecs_ { }) } + pub fn init(&mut self, starting_indexes: &Indexes) -> Height { + self.starting_height = [ + self.height_to_supply.len(), + // self.height_to_unspendable_supply.len(), + self.height_to_utxo_count.len(), + self.height_to_realized_cap + .as_ref() + .map_or(usize::MAX, |v| v.len()), + ] + .into_iter() + .map(Height::from) + .min() + .unwrap() + .min(starting_indexes.height); + + if let Some(prev_height) = self.starting_height.checked_sub(Height::new(1)) { + self.state.supply = self + .height_to_supply + .into_iter() + .unwrap_get_inner(prev_height); + self.state.utxo_count = self + .height_to_utxo_count + .into_iter() + .unwrap_get_inner(prev_height); + if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() { + self.state.realized_cap = height_to_realized_cap + .into_iter() + .unwrap_get_inner(prev_height); + } + } + + self.starting_height + } + + pub fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { + self.height_to_supply + .validate_computed_version_or_reset_file( + base_version + self.height_to_supply.inner_version(), + )?; + + self.height_to_utxo_count + .validate_computed_version_or_reset_file( + base_version + self.height_to_utxo_count.inner_version(), + )?; + + if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut().as_mut() { + height_to_realized_cap.validate_computed_version_or_reset_file( + base_version + height_to_realized_cap.inner_version(), + )?; + } + Ok(()) + } + + pub fn forced_pushed_at(&mut self, height: Height, exit: &Exit) -> Result<()> { + self.height_to_supply + .forced_push_at(height, self.state.supply, exit)?; + + self.height_to_utxo_count + .forced_push_at(height, self.state.utxo_count, exit)?; + + if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() { + height_to_realized_cap.forced_push_at(height, self.state.realized_cap, exit)?; + } + Ok(()) + } + + pub fn safe_flush_height_vecs(&mut self, exit: &Exit) -> Result<()> { + self.height_to_supply.safe_flush(exit)?; + + self.height_to_utxo_count.safe_flush(exit)?; + + if let Some(height_to_realized_cap) = self.height_to_realized_cap.as_mut() { + height_to_realized_cap.safe_flush(exit)?; + } + + Ok(()) + } + + pub fn compute_rest( + &mut self, + indexer: &Indexer, + indexes: &indexes::Vecs, + fetched: Option<&fetched::Vecs>, + starting_indexes: &Indexes, + exit: &Exit, + ) -> color_eyre::Result<()> { + self.indexes_to_supply.compute_rest( + indexer, + indexes, + fetched, + starting_indexes, + exit, + Some(&self.height_to_supply), + )?; + + self.indexes_to_utxo_count.compute_rest( + indexes, + starting_indexes, + exit, + Some(&self.height_to_utxo_count), + )?; + + if let Some(indexes_to_realized_cap) = self.indexes_to_realized_cap.as_mut() { + indexes_to_realized_cap.compute_rest( + indexes, + starting_indexes, + exit, + Some(self.height_to_realized_cap.as_ref().unwrap()), + )?; + } + + Ok(()) + } + pub fn vecs(&self) -> Vec<&dyn AnyCollectableVec> { [ vec![ &self.height_to_supply as &dyn AnyCollectableVec, - &self.height_to_unspendable_supply, &self.height_to_utxo_count, ], self.height_to_realized_cap .as_ref() .map_or(vec![], |v| vec![v as &dyn AnyCollectableVec]), self.indexes_to_supply.vecs(), - self.indexes_to_unspendable_supply.vecs(), self.indexes_to_utxo_count.vecs(), self.indexes_to_realized_cap .as_ref() .map_or(vec![], |v| v.vecs()), ] - .concat() + .into_iter() + .flatten() + .collect::>() + } +} + +impl Clone for Vecs_ { + fn clone(&self) -> Self { + Self { + starting_height: self.starting_height, + state: CohortState::default(), + + height_to_realized_cap: self.height_to_realized_cap.clone(), + indexes_to_realized_cap: self.indexes_to_realized_cap.clone(), + height_to_supply: self.height_to_supply.clone(), + indexes_to_supply: self.indexes_to_supply.clone(), + height_to_utxo_count: self.height_to_utxo_count.clone(), + indexes_to_utxo_count: self.indexes_to_utxo_count.clone(), + } } } diff --git a/crates/brk_core/src/structs/outputtype.rs b/crates/brk_core/src/structs/outputtype.rs index 8345a55eb..1716afdf3 100644 --- a/crates/brk_core/src/structs/outputtype.rs +++ b/crates/brk_core/src/structs/outputtype.rs @@ -32,6 +32,46 @@ pub enum OutputType { Unknown = 255, } +impl OutputType { + pub fn is_spendable(&self) -> bool { + match self { + Self::P2PK65 => true, + Self::P2PK33 => true, + Self::P2PKH => true, + Self::P2MS => true, + Self::P2SH => true, + Self::OpReturn => false, + Self::P2WPKH => true, + Self::P2WSH => true, + Self::P2TR => true, + Self::P2A => true, + Self::Empty => false, + Self::Unknown => false, + } + } + + pub fn is_unspendable(&self) -> bool { + !self.is_spendable() + } + + pub fn as_vec() -> Vec { + vec![ + Self::P2PK65, + Self::P2PK33, + Self::P2PKH, + Self::P2MS, + Self::P2SH, + Self::OpReturn, + Self::P2WPKH, + Self::P2WSH, + Self::P2TR, + Self::P2A, + Self::Empty, + Self::Unknown, + ] + } +} + impl From<&ScriptBuf> for OutputType { fn from(script: &ScriptBuf) -> Self { if script.is_p2pk() { diff --git a/crates/brk_core/src/structs/stored_u32.rs b/crates/brk_core/src/structs/stored_u32.rs index 4b0608a2c..0c90732bc 100644 --- a/crates/brk_core/src/structs/stored_u32.rs +++ b/crates/brk_core/src/structs/stored_u32.rs @@ -15,6 +15,7 @@ use super::{ Debug, Deref, Clone, + Default, Copy, PartialEq, Eq, diff --git a/crates/brk_core/src/structs/timestamp.rs b/crates/brk_core/src/structs/timestamp.rs index 6cec46034..e3fc3d26e 100644 --- a/crates/brk_core/src/structs/timestamp.rs +++ b/crates/brk_core/src/structs/timestamp.rs @@ -1,4 +1,7 @@ -use std::ops::{Add, Div}; +use std::{ + cmp::Ordering, + ops::{Add, Div}, +}; use derive_deref::Deref; use jiff::{civil::date, tz::TimeZone}; @@ -26,6 +29,8 @@ use super::Date; )] pub struct Timestamp(u32); +const ONE_DAY_IN_SEC: i64 = 24 * 60 * 60; + impl Timestamp { pub const ZERO: Self = Self(0); @@ -39,6 +44,19 @@ impl Timestamp { let d = date(d.year(), d.month(), d.day()).at(d.hour(), d.minute(), 0, 0); Self::from(d.to_zoned(TimeZone::UTC).unwrap().timestamp()) } + + pub fn difference_in_days_between(earlier: Self, later: Self) -> usize { + match later.cmp(&earlier) { + Ordering::Less => panic!("Shouldn't be used with inverted"), + Ordering::Equal => 0, + Ordering::Greater => { + (jiff::Timestamp::from(earlier) + .duration_until(jiff::Timestamp::from(later)) + .as_secs() + / ONE_DAY_IN_SEC) as usize + } + } + } } impl From for Timestamp { diff --git a/crates/brk_vec/src/variants/eager.rs b/crates/brk_vec/src/variants/eager.rs index a5e6092ac..165918b87 100644 --- a/crates/brk_vec/src/variants/eager.rs +++ b/crates/brk_vec/src/variants/eager.rs @@ -681,7 +681,7 @@ impl EagerVec { exit: &Exit, ) -> Result<()> { self.validate_computed_version_or_reset_file( - Version::new(5) + self.inner.version() + closes.version(), + Version::ZERO + self.inner.version() + closes.version(), )?; let mut other_iter = closes.iter(); diff --git a/websites/kibo.money/scripts/main.js b/websites/kibo.money/scripts/main.js index f38a2cfa0..879f2694b 100644 --- a/websites/kibo.money/scripts/main.js +++ b/websites/kibo.money/scripts/main.js @@ -740,7 +740,8 @@ function createUtils() { id.includes("coinbase") || id.includes("subsidy") || id.endsWith("stack") || - id.includes("supply") + id.includes("supply") || + id.includes("rewards") ) { unit = "Sats"; } else if ( @@ -798,6 +799,8 @@ function createUtils() { return numberToUSFormat(value, 1); } else if (absoluteValue < 100_000) { return numberToUSFormat(value, 0); + } else if (absoluteValue < 200_000) { + return `${numberToUSFormat(value / 1_000, 2)}K`; } else if (absoluteValue < 1_000_000) { return `${numberToUSFormat(value / 1_000, 1)}K`; } else if (absoluteValue >= 900_000_000_000_000_000) { diff --git a/websites/kibo.money/scripts/options.js b/websites/kibo.money/scripts/options.js index f7139aa88..b5ce94019 100644 --- a/websites/kibo.money/scripts/options.js +++ b/websites/kibo.money/scripts/options.js @@ -325,6 +325,23 @@ function createPartialOptions(colors) { ]; } + /** + * @param {Object} args + * @param {ChartableVecId & VecIdSumBase & TotalVecIdBase} args.key + * @param {string} args.name + */ + function createBaseSumTotalSeries({ key, name }) { + return [ + createBaseSeries({ + key, + name, + }), + ...createSumTotalSeries({ + concat: key, + }), + ]; + } + return [ { name: "Charts", @@ -901,6 +918,24 @@ function createPartialOptions(colors) { ...createAverageSumTotalMinMaxPercentilesSeries("fee-in-usd"), ], }, + { + name: "Unclaimed Rewards", + title: "Unclaimed Rewards", + bottom: [ + ...createBaseSumTotalSeries({ + key: "unclaimed-rewards", + name: "unclaimed", + }), + ...createBaseSumTotalSeries({ + key: "unclaimed-rewards-in-btc", + name: "unclaimed", + }), + ...createBaseSumTotalSeries({ + key: "unclaimed-rewards-in-usd", + name: "unclaimed", + }), + ], + }, { name: "Feerate", title: "Transaction Fee Rate", @@ -1338,62 +1373,62 @@ function createPartialOptions(colors) { { name: "UTXOs", tree: [ - { - name: "supply", - title: "Supply", - bottom: [ - createBaseSeries({ - key: "supply", - name: "Supply", - }), - createBaseSeries({ - key: "supply-in-btc", - name: "Supply", - }), - createBaseSeries({ - key: "supply-in-usd", - name: "Supply", - }), - ], - }, - { - name: "unspendable supply", - title: "Unspendable Supply", - bottom: [ - createBaseSeries({ - key: "unspendable-supply", - name: "Supply", - }), - createBaseSeries({ - key: "unspendable-supply-in-btc", - name: "Supply", - }), - createBaseSeries({ - key: "unspendable-supply-in-usd", - name: "Supply", - }), - ], - }, - { - name: "count", - title: "UTXO Count", - bottom: [ - createBaseSeries({ - key: "utxo-count", - name: "Count", - }), - ], - }, - { - name: "realized cap", - title: "Realized Capitalization", - bottom: [ - createBaseSeries({ - key: "realized-cap", - name: "Realized Cap", - }), - ], - }, + // { + // name: "supply", + // title: "Supply", + // bottom: [ + // createBaseSeries({ + // key: "supply", + // name: "Supply", + // }), + // createBaseSeries({ + // key: "supply-in-btc", + // name: "Supply", + // }), + // createBaseSeries({ + // key: "supply-in-usd", + // name: "Supply", + // }), + // ], + // }, + // { + // name: "unspendable supply", + // title: "Unspendable Supply", + // bottom: [ + // createBaseSeries({ + // key: "unspendable-supply", + // name: "Supply", + // }), + // createBaseSeries({ + // key: "unspendable-supply-in-btc", + // name: "Supply", + // }), + // createBaseSeries({ + // key: "unspendable-supply-in-usd", + // name: "Supply", + // }), + // ], + // }, + // { + // name: "count", + // title: "UTXO Count", + // bottom: [ + // createBaseSeries({ + // key: "utxo-count", + // name: "Count", + // }), + // ], + // }, + // { + // name: "realized cap", + // title: "Realized Capitalization", + // bottom: [ + // createBaseSeries({ + // key: "realized-cap", + // name: "Realized Cap", + // }), + // ], + // }, ], }, ], diff --git a/websites/kibo.money/scripts/vecid-to-indexes.js b/websites/kibo.money/scripts/vecid-to-indexes.js index 830ed8d62..bf28f1b00 100644 --- a/websites/kibo.money/scripts/vecid-to-indexes.js +++ b/websites/kibo.money/scripts/vecid-to-indexes.js @@ -893,7 +893,6 @@ export function createVecIdToIndexes() { "price-8y-ago": [DateIndex, DecadeIndex, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "quarterindex": [MonthIndex, QuarterIndex], "rawlocktime": [TxIndex], - "realized-cap": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "subsidy": [Height], "subsidy-10p": [DateIndex], "subsidy-25p": [DateIndex], @@ -924,9 +923,6 @@ export function createVecIdToIndexes() { "subsidy-median": [DateIndex], "subsidy-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "subsidy-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], - "supply": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], - "supply-in-btc": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], - "supply-in-usd": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "timestamp": [DateIndex, DecadeIndex, DifficultyEpoch, HalvingEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "timestamp-fixed": [Height], "total-block-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], @@ -1017,10 +1013,6 @@ export function createVecIdToIndexes() { "unknownoutput-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "unknownoutput-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "unknownoutputindex": [UnknownOutputIndex], - "unspendable-supply": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], - "unspendable-supply-in-btc": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], - "unspendable-supply-in-usd": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], - "utxo-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "value": [InputIndex, OutputIndex], "vbytes": [Height], "vsize": [TxIndex],