diff --git a/crates/brk_computer/examples/iter.rs b/crates/brk_computer/examples/iter.rs new file mode 100644 index 000000000..0cfee7a33 --- /dev/null +++ b/crates/brk_computer/examples/iter.rs @@ -0,0 +1,65 @@ +use std::path::Path; + +use brk_core::dot_brk_path; +use brk_indexer::Indexer; + +pub fn main() -> color_eyre::Result<()> { + color_eyre::install()?; + + brk_logger::init(Some(Path::new(".log"))); + + let outputs_dir = dot_brk_path().join("outputs"); + // let outputs_dir = Path::new("../../_outputs"); + + let compressed = false; + + let mut indexer = Indexer::new(outputs_dir.as_path(), compressed, true)?; + indexer.import_stores()?; + indexer.import_vecs()?; + + let height_to_timestamp = &indexer.vecs().height_to_timestamp; + + dbg!(height_to_timestamp.len()); + + // height_to_timestamp.iter().for_each(|t| { + // dbg!(t); + // }); + + // let index = max_from.min(A::from(self.len())); + let mut height_to_timestamp_iter = height_to_timestamp.iter(); + // height_to_timestamp.iter().for_each(|t| { + // dbg!(t); + // }); + (0..2).for_each(|i| { + dbg!(height_to_timestamp_iter.get(i)); + }); + // for_each(|t| { + // dbg!(t); + // }); + // .skip(0) + // .try_for_each(|(height, timestamp)| -> Result<()> { + // let interval = height.decremented().map_or(Timestamp::ZERO, |prev_h| { + // dbg!((height, prev_h)); + // let prev_timestamp = height_to_timestamp_iter + // .nth(prev_h.unwrap_to_usize()) + // .context("To work") + // .inspect_err(|_| { + // dbg!(prev_h); + // }) + // .unwrap() + // .1 + // .into_inner(); + // timestamp + // .into_inner() + // .checked_sub(prev_timestamp) + // .unwrap_or(Timestamp::ZERO) + // // Ok(()) + // }); + + // Ok(()) + // // let (i, v) = t((a, b.into_inner(), self, &mut other_iter)); + // // self.forced_push_at(i, v, exit) + // })?; + + Ok(()) +} diff --git a/crates/brk_computer/examples/main.rs b/crates/brk_computer/examples/main.rs index a1961c788..85c1f116c 100644 --- a/crates/brk_computer/examples/main.rs +++ b/crates/brk_computer/examples/main.rs @@ -24,7 +24,7 @@ pub fn main() -> color_eyre::Result<()> { let outputs_dir = Path::new("../../_outputs"); - let compressed = true; + let compressed = false; let mut indexer = Indexer::new(outputs_dir, compressed, true)?; indexer.import_stores()?; diff --git a/crates/brk_computer/src/storage/vecs/blocks.rs b/crates/brk_computer/src/storage/vecs/blocks.rs index 17cd52bb1..84e01751a 100644 --- a/crates/brk_computer/src/storage/vecs/blocks.rs +++ b/crates/brk_computer/src/storage/vecs/blocks.rs @@ -7,7 +7,8 @@ use brk_core::{ use brk_exit::Exit; use brk_indexer::Indexer; use brk_parser::bitcoin; -use brk_vec::{Compressed, Version}; +use brk_vec::{Compressed, StoredIndex, Version}; +use color_eyre::eyre::ContextCompat; use super::{ EagerVec, Indexes, @@ -150,10 +151,18 @@ impl Vecs { self.height_to_interval.compute_transform( starting_indexes.height, - indexer_vecs.height_to_timestamp.mut_vec(), - |(height, timestamp, _, height_to_timestamp)| { + indexer_vecs.height_to_timestamp.vec(), + |(height, timestamp, _, height_to_timestamp_iter)| { let interval = height.decremented().map_or(Timestamp::ZERO, |prev_h| { - let prev_timestamp = height_to_timestamp.double_unwrap_cached_get(prev_h); + let prev_timestamp = height_to_timestamp_iter + .get(prev_h.unwrap_to_usize()) + .context("To work") + .inspect_err(|_| { + dbg!(prev_h); + }) + .unwrap() + .1 + .into_inner(); timestamp .checked_sub(prev_timestamp) .unwrap_or(Timestamp::ZERO) diff --git a/crates/brk_computer/src/storage/vecs/grouped/builder.rs b/crates/brk_computer/src/storage/vecs/grouped/builder.rs index da4730d39..80549453b 100644 --- a/crates/brk_computer/src/storage/vecs/grouped/builder.rs +++ b/crates/brk_computer/src/storage/vecs/grouped/builder.rs @@ -145,20 +145,22 @@ where let total_vec = self.total.as_mut().unwrap(); - source.iter_from(index, |(i, v, ..)| { - let prev = i - .unwrap_to_usize() - .checked_sub(1) - .map_or(T::from(0_usize), |prev_i| { - total_vec - .unwrap_cached_get(I::from(prev_i)) - .unwrap_or(T::from(0_usize)) - }); - let value = v.clone() + prev; - total_vec.forced_push_at(i, value, exit)?; - - Ok(()) - })?; + source + .into_iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, v)| -> Result<()> { + let v = v.into_inner(); + let prev = i + .unwrap_to_usize() + .checked_sub(1) + .map_or(T::from(0_usize), |prev_i| { + total_vec + .unwrap_cached_get(I::from(prev_i)) + .unwrap_or(T::from(0_usize)) + }); + let value = v.clone() + prev; + total_vec.forced_push_at(i, value, exit) + })?; self.safe_flush(exit)?; @@ -178,114 +180,119 @@ where { let index = self.starting_index(max_from); - first_indexes.iter_from(index, |(i, first_index, first_indexes)| { - let last_index = last_indexes.double_unwrap_cached_get(i); + first_indexes + .into_iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, first_index)| -> Result<()> { + let first_index = first_index.into_inner(); - if let Some(first) = self.first.as_mut() { - let v = source.double_unwrap_cached_get(first_index); - first.forced_push_at(index, v, exit)?; - } + let last_index = last_indexes.double_unwrap_cached_get(i); - if let Some(last) = self.last.as_mut() { - let v = source.double_unwrap_cached_get(last_index); - last.forced_push_at(index, v, exit)?; - } - - let needs_sum_or_total = self.sum.is_some() || self.total.is_some(); - let needs_average_sum_or_total = needs_sum_or_total || self.average.is_some(); - let needs_sorted = self.max.is_some() - || self._90p.is_some() - || self._75p.is_some() - || self.median.is_some() - || self._25p.is_some() - || self._10p.is_some() - || self.min.is_some(); - let needs_values = needs_sorted || needs_average_sum_or_total; - - if needs_values { - let mut values = source.collect_inclusive_range(first_index, last_index)?; - - if needs_sorted { - values.sort_unstable(); - - if let Some(max) = self.max.as_mut() { - max.forced_push_at( - i, - values - .last() - .context("expect some") - .inspect_err(|_| { - dbg!( - &values, - max.path(), - first_indexes.path(), - first_index, - last_indexes.path(), - last_index, - source.len(), - source.path() - ); - }) - .unwrap() - .clone(), - exit, - )?; - } - - if let Some(_90p) = self._90p.as_mut() { - _90p.forced_push_at(i, Self::get_percentile(&values, 0.90), exit)?; - } - - if let Some(_75p) = self._75p.as_mut() { - _75p.forced_push_at(i, Self::get_percentile(&values, 0.75), exit)?; - } - - if let Some(median) = self.median.as_mut() { - median.forced_push_at(i, Self::get_percentile(&values, 0.50), exit)?; - } - - if let Some(_25p) = self._25p.as_mut() { - _25p.forced_push_at(i, Self::get_percentile(&values, 0.25), exit)?; - } - - if let Some(_10p) = self._10p.as_mut() { - _10p.forced_push_at(i, Self::get_percentile(&values, 0.10), exit)?; - } - - if let Some(min) = self.min.as_mut() { - min.forced_push_at(i, values.first().unwrap().clone(), exit)?; - } + if let Some(first) = self.first.as_mut() { + let v = source.double_unwrap_cached_get(first_index); + first.forced_push_at(index, v, exit)?; } - if needs_average_sum_or_total { - let len = values.len(); - let sum = values.into_iter().fold(T::from(0), |a, b| a + b); + if let Some(last) = self.last.as_mut() { + let v = source.double_unwrap_cached_get(last_index); + last.forced_push_at(index, v, exit)?; + } - if let Some(average) = self.average.as_mut() { - let avg = sum.clone() / len; - average.forced_push_at(i, avg, exit)?; - } + let needs_sum_or_total = self.sum.is_some() || self.total.is_some(); + let needs_average_sum_or_total = needs_sum_or_total || self.average.is_some(); + let needs_sorted = self.max.is_some() + || self._90p.is_some() + || self._75p.is_some() + || self.median.is_some() + || self._25p.is_some() + || self._10p.is_some() + || self.min.is_some(); + let needs_values = needs_sorted || needs_average_sum_or_total; - if needs_sum_or_total { - if let Some(sum_vec) = self.sum.as_mut() { - sum_vec.forced_push_at(i, sum.clone(), exit)?; + if needs_values { + let mut values = source.collect_inclusive_range(first_index, last_index)?; + + if needs_sorted { + values.sort_unstable(); + + if let Some(max) = self.max.as_mut() { + max.forced_push_at( + i, + values + .last() + .context("expect some") + .inspect_err(|_| { + dbg!( + &values, + max.path(), + first_indexes.path(), + first_index, + last_indexes.path(), + last_index, + source.len(), + source.path() + ); + }) + .unwrap() + .clone(), + exit, + )?; } - if let Some(total_vec) = self.total.as_mut() { - let prev = i - .unwrap_to_usize() - .checked_sub(1) - .map_or(T::from(0_usize), |prev_i| { - total_vec.double_unwrap_cached_get(I::from(prev_i)) - }); - total_vec.forced_push_at(i, prev + sum, exit)?; + if let Some(_90p) = self._90p.as_mut() { + _90p.forced_push_at(i, Self::get_percentile(&values, 0.90), exit)?; + } + + if let Some(_75p) = self._75p.as_mut() { + _75p.forced_push_at(i, Self::get_percentile(&values, 0.75), exit)?; + } + + if let Some(median) = self.median.as_mut() { + median.forced_push_at(i, Self::get_percentile(&values, 0.50), exit)?; + } + + if let Some(_25p) = self._25p.as_mut() { + _25p.forced_push_at(i, Self::get_percentile(&values, 0.25), exit)?; + } + + if let Some(_10p) = self._10p.as_mut() { + _10p.forced_push_at(i, Self::get_percentile(&values, 0.10), exit)?; + } + + if let Some(min) = self.min.as_mut() { + min.forced_push_at(i, values.first().unwrap().clone(), exit)?; + } + } + + if needs_average_sum_or_total { + let len = values.len(); + let sum = values.into_iter().fold(T::from(0), |a, b| a + b); + + if let Some(average) = self.average.as_mut() { + let avg = sum.clone() / len; + average.forced_push_at(i, avg, exit)?; + } + + if needs_sum_or_total { + if let Some(sum_vec) = self.sum.as_mut() { + sum_vec.forced_push_at(i, sum.clone(), exit)?; + } + + if let Some(total_vec) = self.total.as_mut() { + let prev = i + .unwrap_to_usize() + .checked_sub(1) + .map_or(T::from(0_usize), |prev_i| { + total_vec.double_unwrap_cached_get(I::from(prev_i)) + }); + total_vec.forced_push_at(i, prev + sum, exit)?; + } } } } - } - Ok(()) - })?; + Ok(()) + })?; self.safe_flush(exit)?; @@ -315,99 +322,104 @@ where let index = self.starting_index(max_from); - first_indexes.iter_from(index, |(i, first_index, ..)| { - let last_index = last_indexes.double_unwrap_cached_get(i); + first_indexes + .into_iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, first_index, ..)| -> Result<()> { + let first_index = first_index.into_inner(); - if let Some(first) = self.first.as_mut() { - let v = source - .first - .as_mut() - .unwrap() - .double_unwrap_cached_get(first_index); - first.forced_push_at(index, v, exit)?; - } + let last_index = last_indexes.double_unwrap_cached_get(i); - if let Some(last) = self.last.as_mut() { - let v = source - .last - .as_mut() - .unwrap() - .double_unwrap_cached_get(last_index); - last.forced_push_at(index, v, exit)?; - } - - let needs_sum_or_total = self.sum.is_some() || self.total.is_some(); - let needs_average_sum_or_total = needs_sum_or_total || self.average.is_some(); - let needs_sorted = self.max.is_some() || self.min.is_some(); - let needs_values = needs_sorted || needs_average_sum_or_total; - - if needs_values { - if needs_sorted { - if let Some(max) = self.max.as_mut() { - let mut values = source - .max - .as_ref() - .unwrap() - .collect_inclusive_range(first_index, last_index)?; - values.sort_unstable(); - max.forced_push_at(i, values.last().unwrap().clone(), exit)?; - } - - if let Some(min) = self.min.as_mut() { - let mut values = source - .min - .as_ref() - .unwrap() - .collect_inclusive_range(first_index, last_index)?; - values.sort_unstable(); - min.forced_push_at(i, values.first().unwrap().clone(), exit)?; - } + if let Some(first) = self.first.as_mut() { + let v = source + .first + .as_mut() + .unwrap() + .double_unwrap_cached_get(first_index); + first.forced_push_at(index, v, exit)?; } - if needs_average_sum_or_total { - if let Some(average) = self.average.as_mut() { - let values = source - .average - .as_ref() - .unwrap() - .collect_inclusive_range(first_index, last_index)?; + if let Some(last) = self.last.as_mut() { + let v = source + .last + .as_mut() + .unwrap() + .double_unwrap_cached_get(last_index); + last.forced_push_at(index, v, exit)?; + } - let len = values.len(); - let total = values.into_iter().fold(T::from(0), |a, b| a + b); - // TODO: Multiply by count then divide by total - // Right now it's not 100% accurate as there could be more or less elements in the lower timeframe (28 days vs 31 days in a month for example) - let avg = total / len; - average.forced_push_at(i, avg, exit)?; - } + let needs_sum_or_total = self.sum.is_some() || self.total.is_some(); + let needs_average_sum_or_total = needs_sum_or_total || self.average.is_some(); + let needs_sorted = self.max.is_some() || self.min.is_some(); + let needs_values = needs_sorted || needs_average_sum_or_total; - if needs_sum_or_total { - let values = source - .sum - .as_ref() - .unwrap() - .collect_inclusive_range(first_index, last_index)?; - - let sum = values.into_iter().fold(T::from(0), |a, b| a + b); - - if let Some(sum_vec) = self.sum.as_mut() { - sum_vec.forced_push_at(i, sum.clone(), exit)?; + if needs_values { + if needs_sorted { + if let Some(max) = self.max.as_mut() { + let mut values = source + .max + .as_ref() + .unwrap() + .collect_inclusive_range(first_index, last_index)?; + values.sort_unstable(); + max.forced_push_at(i, values.last().unwrap().clone(), exit)?; } - if let Some(total_vec) = self.total.as_mut() { - let prev = i - .unwrap_to_usize() - .checked_sub(1) - .map_or(T::from(0_usize), |prev_i| { - total_vec.double_unwrap_cached_get(I::from(prev_i)) - }); - total_vec.forced_push_at(i, prev + sum, exit)?; + if let Some(min) = self.min.as_mut() { + let mut values = source + .min + .as_ref() + .unwrap() + .collect_inclusive_range(first_index, last_index)?; + values.sort_unstable(); + min.forced_push_at(i, values.first().unwrap().clone(), exit)?; + } + } + + if needs_average_sum_or_total { + if let Some(average) = self.average.as_mut() { + let values = source + .average + .as_ref() + .unwrap() + .collect_inclusive_range(first_index, last_index)?; + + let len = values.len(); + let total = values.into_iter().fold(T::from(0), |a, b| a + b); + // TODO: Multiply by count then divide by total + // Right now it's not 100% accurate as there could be more or less elements in the lower timeframe (28 days vs 31 days in a month for example) + let avg = total / len; + average.forced_push_at(i, avg, exit)?; + } + + if needs_sum_or_total { + let values = source + .sum + .as_ref() + .unwrap() + .collect_inclusive_range(first_index, last_index)?; + + let sum = values.into_iter().fold(T::from(0), |a, b| a + b); + + if let Some(sum_vec) = self.sum.as_mut() { + sum_vec.forced_push_at(i, sum.clone(), exit)?; + } + + if let Some(total_vec) = self.total.as_mut() { + let prev = i + .unwrap_to_usize() + .checked_sub(1) + .map_or(T::from(0_usize), |prev_i| { + total_vec.double_unwrap_cached_get(I::from(prev_i)) + }); + total_vec.forced_push_at(i, prev + sum, exit)?; + } } } } - } - Ok(()) - })?; + Ok(()) + })?; self.safe_flush(exit)?; diff --git a/crates/brk_computer/src/storage/vecs/indexes.rs b/crates/brk_computer/src/storage/vecs/indexes.rs index b4d181791..ae680372d 100644 --- a/crates/brk_computer/src/storage/vecs/indexes.rs +++ b/crates/brk_computer/src/storage/vecs/indexes.rs @@ -36,7 +36,19 @@ pub struct Vecs { pub height_to_difficultyepoch: EagerVec, pub height_to_halvingepoch: EagerVec, pub height_to_height: EagerVec, + pub height_to_last_emptyoutputindex: EagerVec, + pub height_to_last_opreturnindex: EagerVec, + pub height_to_last_p2aindex: EagerVec, + pub height_to_last_p2msindex: EagerVec, + pub height_to_last_p2pk33index: EagerVec, + pub height_to_last_p2pk65index: EagerVec, + pub height_to_last_p2pkhindex: EagerVec, + pub height_to_last_p2shindex: EagerVec, + pub height_to_last_p2trindex: EagerVec, + pub height_to_last_p2wpkhindex: EagerVec, + pub height_to_last_p2wshindex: EagerVec, pub height_to_last_txindex: EagerVec, + pub height_to_last_unknownoutputindex: EagerVec, pub height_to_timestamp_fixed: EagerVec, pub inputindex_to_inputindex: EagerVec, pub monthindex_to_first_dateindex: EagerVec, @@ -357,6 +369,66 @@ impl Vecs { Version::ZERO, compressed, )?, + height_to_last_p2aindex: EagerVec::forced_import( + &path.join("height_to_last_p2aindex"), + Version::ZERO, + compressed, + )?, + height_to_last_p2msindex: EagerVec::forced_import( + &path.join("height_to_last_p2msindex"), + Version::ZERO, + compressed, + )?, + height_to_last_p2pk33index: EagerVec::forced_import( + &path.join("height_to_last_p2pk33index"), + Version::ZERO, + compressed, + )?, + height_to_last_p2pk65index: EagerVec::forced_import( + &path.join("height_to_last_p2pk65index"), + Version::ZERO, + compressed, + )?, + height_to_last_p2pkhindex: EagerVec::forced_import( + &path.join("height_to_last_p2pkhindex"), + Version::ZERO, + compressed, + )?, + height_to_last_p2shindex: EagerVec::forced_import( + &path.join("height_to_last_p2shindex"), + Version::ZERO, + compressed, + )?, + height_to_last_p2trindex: EagerVec::forced_import( + &path.join("height_to_last_p2trindex"), + Version::ZERO, + compressed, + )?, + height_to_last_p2wpkhindex: EagerVec::forced_import( + &path.join("height_to_last_p2wpkhindex"), + Version::ZERO, + compressed, + )?, + height_to_last_p2wshindex: EagerVec::forced_import( + &path.join("height_to_last_p2wshindex"), + Version::ZERO, + compressed, + )?, + height_to_last_opreturnindex: EagerVec::forced_import( + &path.join("height_to_last_opreturnindex"), + Version::ZERO, + compressed, + )?, + height_to_last_unknownoutputindex: EagerVec::forced_import( + &path.join("height_to_last_unknownoutputindex"), + Version::ZERO, + compressed, + )?, + height_to_last_emptyoutputindex: EagerVec::forced_import( + &path.join("height_to_last_emptyoutputindex"), + Version::ZERO, + compressed, + )?, }) } @@ -469,6 +541,101 @@ impl Vecs { exit, )?; + self.height_to_last_p2aindex.compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2aindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2msindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2msindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2pk33index + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2pk33index.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2pk65index + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2pk65index.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2pkhindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2pkhindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2shindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2shindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2trindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2trindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2wpkhindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2wpkhindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_p2wshindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_p2wshindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_opreturnindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_opreturnindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_unknownoutputindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_unknownoutputindex.mut_vec(), + height_count, + exit, + )?; + + self.height_to_last_emptyoutputindex + .compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_emptyoutputindex.mut_vec(), + height_count, + exit, + )?; + // --- // InputIndex // --- @@ -959,6 +1126,18 @@ impl Vecs { self.p2aindex_to_p2aindex.any_vec(), self.unknownoutputindex_to_unknownoutputindex.any_vec(), self.outputindex_to_outputindex.any_vec(), + self.height_to_last_p2aindex.any_vec(), + self.height_to_last_p2msindex.any_vec(), + self.height_to_last_p2pk33index.any_vec(), + self.height_to_last_p2pk65index.any_vec(), + self.height_to_last_p2pkhindex.any_vec(), + self.height_to_last_p2shindex.any_vec(), + self.height_to_last_p2trindex.any_vec(), + self.height_to_last_p2wpkhindex.any_vec(), + self.height_to_last_p2wshindex.any_vec(), + self.height_to_last_opreturnindex.any_vec(), + self.height_to_last_unknownoutputindex.any_vec(), + self.height_to_last_emptyoutputindex.any_vec(), ] } } diff --git a/crates/brk_computer/src/storage/vecs/marketprice.rs b/crates/brk_computer/src/storage/vecs/marketprice.rs index dd62bc5f4..51d59a756 100644 --- a/crates/brk_computer/src/storage/vecs/marketprice.rs +++ b/crates/brk_computer/src/storage/vecs/marketprice.rs @@ -7,7 +7,7 @@ use brk_core::{ use brk_exit::Exit; use brk_fetcher::Fetcher; use brk_indexer::Indexer; -use brk_vec::{Compressed, Version}; +use brk_vec::{Compressed, StoredIndex, Version}; use super::{ EagerVec, Indexes, @@ -336,13 +336,18 @@ impl Vecs { self.height_to_ohlc_in_cents.compute_transform( starting_indexes.height, indexer_vecs.height_to_timestamp.mut_vec(), - |(h, t, _, height_to_timestamp)| { + |(h, t, _, height_to_timestamp_iter)| { let ohlc = fetcher .get_height( h, t, - h.decremented() - .map(|prev_h| height_to_timestamp.double_unwrap_cached_get(prev_h)), + h.decremented().map(|prev_h| { + height_to_timestamp_iter + .get(prev_h.unwrap_to_usize()) + .unwrap() + .1 + .into_inner() + }), ) .unwrap(); (h, ohlc) diff --git a/crates/brk_computer/src/storage/vecs/mod.rs b/crates/brk_computer/src/storage/vecs/mod.rs index ee2284758..f9fde58b5 100644 --- a/crates/brk_computer/src/storage/vecs/mod.rs +++ b/crates/brk_computer/src/storage/vecs/mod.rs @@ -21,7 +21,7 @@ pub struct Vecs { pub blocks: blocks::Vecs, pub indexes: indexes::Vecs, pub mining: mining::Vecs, - // pub transactions: transactions::Vecs, + pub transactions: transactions::Vecs, pub marketprice: Option, } @@ -33,7 +33,7 @@ impl Vecs { blocks: blocks::Vecs::forced_import(path, compressed)?, indexes: indexes::Vecs::forced_import(path, compressed)?, mining: mining::Vecs::forced_import(path, compressed)?, - // transactions: transactions::Vecs::forced_import(path, compressed, fetch)?, + transactions: transactions::Vecs::forced_import(path, compressed, fetch)?, marketprice: fetch.then(|| marketprice::Vecs::forced_import(path, compressed).unwrap()), }) } @@ -63,13 +63,13 @@ impl Vecs { )?; } - // self.transactions.compute( - // indexer, - // &mut self.indexes, - // &starting_indexes, - // &mut self.marketprice.as_mut(), - // exit, - // )?; + self.transactions.compute( + indexer, + &mut self.indexes, + &starting_indexes, + &mut self.marketprice.as_mut(), + exit, + )?; Ok(()) } @@ -79,7 +79,7 @@ impl Vecs { self.indexes.as_any_vecs(), self.blocks.as_any_vecs(), self.mining.as_any_vecs(), - // self.transactions.as_any_vecs(), + self.transactions.as_any_vecs(), self.marketprice .as_ref() .map_or(vec![], |v| v.as_any_vecs()), diff --git a/crates/brk_computer/src/storage/vecs/transactions.rs b/crates/brk_computer/src/storage/vecs/transactions.rs index a10d8bdae..59d64ae5e 100644 --- a/crates/brk_computer/src/storage/vecs/transactions.rs +++ b/crates/brk_computer/src/storage/vecs/transactions.rs @@ -20,28 +20,40 @@ use super::{ #[derive(Clone)] pub struct Vecs { - pub indexes_to_tx_count: ComputedVecsFromHeight, + // pub txindex_to_is_v1: LazyVec, + // pub txindex_to_is_v2: LazyVec, + // pub txindex_to_is_v3: LazyVec, + pub indexes_to_coinbase: ComputedValueVecsFromHeight, + pub indexes_to_emptyoutput_count: ComputedVecsFromHeight, pub indexes_to_fee: ComputedValueVecsFromTxindex, pub indexes_to_feerate: ComputedVecsFromTxindex, + /// Value == 0 when Coinbase pub indexes_to_input_value: ComputedVecsFromTxindex, + pub indexes_to_opreturn_count: ComputedVecsFromHeight, pub indexes_to_output_value: ComputedVecsFromTxindex, - // pub txindex_to_is_v1: LazyVec, + pub indexes_to_p2a_count: ComputedVecsFromHeight, + pub indexes_to_p2ms_count: ComputedVecsFromHeight, + pub indexes_to_p2pk33_count: ComputedVecsFromHeight, + pub indexes_to_p2pk65_count: ComputedVecsFromHeight, + pub indexes_to_p2pkh_count: ComputedVecsFromHeight, + pub indexes_to_p2sh_count: ComputedVecsFromHeight, + pub indexes_to_p2tr_count: ComputedVecsFromHeight, + pub indexes_to_p2wpkh_count: ComputedVecsFromHeight, + pub indexes_to_p2wsh_count: ComputedVecsFromHeight, + pub indexes_to_subsidy: ComputedValueVecsFromHeight, + pub indexes_to_tx_count: ComputedVecsFromHeight, pub indexes_to_tx_v1: ComputedVecsFromHeight, - // pub txindex_to_is_v2: LazyVec, pub indexes_to_tx_v2: ComputedVecsFromHeight, - // pub txindex_to_is_v3: LazyVec, pub indexes_to_tx_v3: ComputedVecsFromHeight, pub indexes_to_tx_vsize: ComputedVecsFromTxindex, pub indexes_to_tx_weight: ComputedVecsFromTxindex, + pub indexes_to_unknownoutput_count: ComputedVecsFromHeight, + pub inputindex_to_value: EagerVec, pub txindex_to_input_count: ComputedVecsFromTxindex, pub txindex_to_is_coinbase: EagerVec, pub txindex_to_output_count: ComputedVecsFromTxindex, pub txindex_to_vsize: EagerVec, pub txindex_to_weight: EagerVec, - /// Value == 0 when Coinbase - pub inputindex_to_value: EagerVec, - pub indexes_to_subsidy: ComputedValueVecsFromHeight, - pub indexes_to_coinbase: ComputedValueVecsFromHeight, } impl Vecs { @@ -234,6 +246,162 @@ impl Vecs { .add_average(), compute_dollars, )?, + indexes_to_p2a_count: ComputedVecsFromHeight::forced_import( + path, + "p2a_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2ms_count: ComputedVecsFromHeight::forced_import( + path, + "p2ms_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2pk33_count: ComputedVecsFromHeight::forced_import( + path, + "p2pk33_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2pk65_count: ComputedVecsFromHeight::forced_import( + path, + "p2pk65_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2pkh_count: ComputedVecsFromHeight::forced_import( + path, + "p2pkh_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2sh_count: ComputedVecsFromHeight::forced_import( + path, + "p2sh_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2tr_count: ComputedVecsFromHeight::forced_import( + path, + "p2tr_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2wpkh_count: ComputedVecsFromHeight::forced_import( + path, + "p2wpkh_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_p2wsh_count: ComputedVecsFromHeight::forced_import( + path, + "p2wsh_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_opreturn_count: ComputedVecsFromHeight::forced_import( + path, + "opreturn_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_unknownoutput_count: ComputedVecsFromHeight::forced_import( + path, + "unknownoutput_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, + indexes_to_emptyoutput_count: ComputedVecsFromHeight::forced_import( + path, + "emptyoutput_count", + true, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default() + .add_average() + .add_minmax() + .add_percentiles() + .add_sum() + .add_total(), + )?, }) } @@ -356,10 +524,11 @@ impl Vecs { exit, )?; + let inputs_len = indexer_vecs.inputindex_to_outputindex.vec().len(); self.inputindex_to_value.compute_transform( starting_indexes.inputindex, indexer_vecs.inputindex_to_outputindex.mut_vec(), - |(inputindex, outputindex, slf, other)| { + |(inputindex, outputindex, slf, ..)| { let value = if outputindex == OutputIndex::COINBASE { Sats::ZERO } else if let Some(value) = indexer_vecs @@ -369,7 +538,7 @@ impl Vecs { { value } else { - dbg!(inputindex, outputindex, slf.len(), other.len()); + dbg!(inputindex, outputindex, slf.len(), inputs_len); panic!() }; (inputindex, value) @@ -547,6 +716,181 @@ impl Vecs { }, )?; + self.indexes_to_p2a_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2aindex.mut_vec(), + indexes.height_to_last_p2aindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2ms_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2msindex.mut_vec(), + indexes.height_to_last_p2msindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2pk33_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2pk33index.mut_vec(), + indexes.height_to_last_p2pk33index.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2pk65_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2pk65index.mut_vec(), + indexes.height_to_last_p2pk65index.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2pkh_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2pkhindex.mut_vec(), + indexes.height_to_last_p2pkhindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2sh_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2shindex.mut_vec(), + indexes.height_to_last_p2shindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2tr_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2trindex.mut_vec(), + indexes.height_to_last_p2trindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2wpkh_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2wpkhindex.mut_vec(), + indexes.height_to_last_p2wpkhindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_p2wsh_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_p2wshindex.mut_vec(), + indexes.height_to_last_p2wshindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_opreturn_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer.mut_vecs().height_to_first_opreturnindex.mut_vec(), + indexes.height_to_last_opreturnindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_unknownoutput_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer + .mut_vecs() + .height_to_first_unknownoutputindex + .mut_vec(), + indexes.height_to_last_unknownoutputindex.mut_vec(), + exit, + ) + }, + )?; + self.indexes_to_emptyoutput_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.height, + indexer + .mut_vecs() + .height_to_first_emptyoutputindex + .mut_vec(), + indexes.height_to_last_emptyoutputindex.mut_vec(), + exit, + ) + }, + )?; + Ok(()) } @@ -572,6 +916,18 @@ impl Vecs { self.indexes_to_tx_weight.any_vecs(), self.txindex_to_input_count.any_vecs(), self.txindex_to_output_count.any_vecs(), + self.indexes_to_p2a_count.any_vecs(), + self.indexes_to_p2ms_count.any_vecs(), + self.indexes_to_p2pk33_count.any_vecs(), + self.indexes_to_p2pk65_count.any_vecs(), + self.indexes_to_p2pkh_count.any_vecs(), + self.indexes_to_p2sh_count.any_vecs(), + self.indexes_to_p2tr_count.any_vecs(), + self.indexes_to_p2wpkh_count.any_vecs(), + self.indexes_to_p2wsh_count.any_vecs(), + self.indexes_to_opreturn_count.any_vecs(), + self.indexes_to_unknownoutput_count.any_vecs(), + self.indexes_to_emptyoutput_count.any_vecs(), ] .concat() } diff --git a/crates/brk_computer/src/storage/vecs/vec/eager.rs b/crates/brk_computer/src/storage/vecs/vec/eager.rs index f64f1533d..a13cf4467 100644 --- a/crates/brk_computer/src/storage/vecs/vec/eager.rs +++ b/crates/brk_computer/src/storage/vecs/vec/eager.rs @@ -9,7 +9,8 @@ use std::{ use brk_core::{Bitcoin, CheckedSub, Close, Dollars, Height, Sats, TxIndex}; use brk_exit::Exit; use brk_vec::{ - Compressed, DynamicVec, Error, GenericVec, Result, StoredIndex, StoredType, StoredVec, Version, + Compressed, DynamicVec, Error, GenericVec, Result, StoredIndex, StoredType, StoredVec, + StoredVecIterator, Version, }; use log::info; @@ -181,24 +182,28 @@ where pub fn compute_transform( &mut self, max_from: A, - other: &mut StoredVec, + other: &StoredVec, mut t: F, exit: &Exit, ) -> Result<()> where A: StoredIndex, B: StoredType, - F: FnMut((A, B, &mut Self, &mut dyn DynamicVec)) -> (I, T), + F: FnMut((A, B, &mut Self, &'_ mut StoredVecIterator<'_, A, B>)) -> (I, T), { self.validate_computed_version_or_reset_file( Version::ZERO + self.version() + other.version(), )?; let index = max_from.min(A::from(self.len())); - other.iter_from(index, |(a, b, other)| { - let (i, v) = t((a, b, self, other)); - self.forced_push_at(i, v, exit) - })?; + let mut other_iter = other.iter(); + other + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(a, b)| { + let (i, v) = t((a, b.into_inner(), self, &mut other_iter)); + self.forced_push_at(i, v, exit) + })?; self.safe_flush(exit) } @@ -222,13 +227,17 @@ where .cached_get_last()? .map_or_else(T::default, |v| v.into_inner()), ); - other.iter_from(index, |(v, i, ..)| { - if self.unwrap_cached_get(i).is_none_or(|old_v| old_v > v) { - self.forced_push_at(i, v, exit) - } else { - Ok(()) - } - })?; + other + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(v, i)| { + let i = i.into_inner(); + if self.unwrap_cached_get(i).is_none_or(|old_v| old_v > v) { + self.forced_push_at(i, v, exit) + } else { + Ok(()) + } + })?; self.safe_flush(exit) } @@ -249,12 +258,15 @@ where )?; let index = max_from.min(T::from(self.len())); - first_indexes.iter_from(index, |(value, first_index, ..)| { - let first_index = (first_index).to_usize()?; - let last_index = (last_indexes.double_unwrap_cached_get(value)).to_usize()?; - (first_index..=last_index) - .try_for_each(|index| self.forced_push_at(I::from(index), value, exit)) - })?; + first_indexes + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(value, first_index)| { + let first_index = (first_index).to_usize()?; + let last_index = (last_indexes.double_unwrap_cached_get(value)).to_usize()?; + (first_index..=last_index) + .try_for_each(|index| self.forced_push_at(I::from(index), value, exit)) + })?; self.safe_flush(exit) } @@ -276,14 +288,17 @@ where let index = max_from.min(I::from(self.len())); let one = T::from(1); let mut prev_index: Option = None; - first_indexes.iter_from(index, |(index, v, ..)| { - if let Some(prev_index) = prev_index.take() { - let value = v.checked_sub(one).unwrap(); - self.forced_push_at(prev_index, value, exit)?; - } - prev_index.replace(index); - Ok(()) - })?; + first_indexes + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(index, v)| -> Result<()> { + if let Some(prev_index) = prev_index.take() { + let value = v.checked_sub(one).unwrap(); + self.forced_push_at(prev_index, value, exit)?; + } + prev_index.replace(index); + Ok(()) + })?; if let Some(prev_index) = prev_index { self.forced_push_at( prev_index, @@ -370,16 +385,19 @@ where )?; let index = max_from.min(I::from(self.len())); - first_indexes.iter_from(index, |(i, first_index, ..)| { - let last_index = last_indexes.double_unwrap_cached_get(i); - let range = first_index.unwrap_to_usize()..=last_index.unwrap_to_usize(); - let count = if let Some(filter) = filter.as_mut() { - range.into_iter().filter(|i| filter(T2::from(*i))).count() - } else { - range.count() - }; - self.forced_push_at(i, T::from(T2::from(count)), exit) - })?; + first_indexes + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, first_index)| { + let last_index = last_indexes.double_unwrap_cached_get(i); + let range = first_index.unwrap_to_usize()..=last_index.unwrap_to_usize(); + let count = if let Some(filter) = filter.as_mut() { + range.into_iter().filter(|i| filter(T2::from(*i))).count() + } else { + range.count() + }; + self.forced_push_at(i, T::from(T2::from(count)), exit) + })?; self.safe_flush(exit) } @@ -401,13 +419,16 @@ where )?; let index = max_from.min(I::from(self.len())); - self_to_other.iter_from(index, |(i, other, ..)| { - self.forced_push_at( - i, - T::from(other_to_self.double_unwrap_cached_get(other) == i), - exit, - ) - })?; + self_to_other + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, other)| { + self.forced_push_at( + i, + T::from(other_to_self.double_unwrap_cached_get(other.into_inner()) == i), + exit, + ) + })?; self.safe_flush(exit) } @@ -429,15 +450,18 @@ where )?; let index = max_from.min(I::from(self.len())); - first_indexes.iter_from(index, |(i, first_index, ..)| { - let last_index = last_indexes.double_unwrap_cached_get(i); - let range = first_index.unwrap_to_usize()..=last_index.unwrap_to_usize(); - let mut sum = T::from(0_usize); - range.into_iter().for_each(|i| { - sum = sum.clone() + source.double_unwrap_cached_get(T2::from(i)); - }); - self.forced_push_at(i, sum, exit) - })?; + first_indexes + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, first_index)| { + let last_index = last_indexes.double_unwrap_cached_get(i); + let range = first_index.unwrap_to_usize()..=last_index.unwrap_to_usize(); + let mut sum = T::from(0_usize); + range.into_iter().for_each(|i| { + sum = sum.clone() + source.double_unwrap_cached_get(T2::from(i)); + }); + self.forced_push_at(i, sum, exit) + })?; self.safe_flush(exit) } @@ -458,10 +482,12 @@ where )?; let index = max_from.min(I::from(self.len())); - sats.iter_from(index, |(i, sats, ..)| { - let (i, v) = (i, Bitcoin::from(sats)); - self.forced_push_at(i, v, exit) - })?; + sats.iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, sats)| { + let (i, v) = (i, Bitcoin::from(sats.into_inner())); + self.forced_push_at(i, v, exit) + })?; self.safe_flush(exit) } @@ -480,11 +506,14 @@ impl EagerVec { )?; let index = max_from.min(Height::from(self.len())); - bitcoin.iter_from(index, |(i, bitcoin, ..)| { - let dollars = price.double_unwrap_cached_get(i); - let (i, v) = (i, *dollars * bitcoin); - self.forced_push_at(i, v, exit) - })?; + bitcoin + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, bitcoin)| { + let dollars = price.double_unwrap_cached_get(i); + let (i, v) = (i, *dollars * bitcoin.into_inner()); + self.forced_push_at(i, v, exit) + })?; self.safe_flush(exit) } @@ -504,12 +533,15 @@ impl EagerVec { )?; let index = max_from.min(TxIndex::from(self.len())); - bitcoin.iter_from(index, |(i, bitcoin, ..)| { - let height = i_to_height.double_unwrap_cached_get(i); - let dollars = price.double_unwrap_cached_get(height); - let (i, v) = (i, *dollars * bitcoin); - self.forced_push_at(i, v, exit) - })?; + bitcoin + .iter() + .skip(index.unwrap_to_usize()) + .try_for_each(|(i, bitcoin, ..)| { + let height = i_to_height.double_unwrap_cached_get(i); + let dollars = price.double_unwrap_cached_get(height); + let (i, v) = (i, *dollars * bitcoin.into_inner()); + self.forced_push_at(i, v, exit) + })?; self.safe_flush(exit) } diff --git a/crates/brk_core/src/structs/outputtypeindex.rs b/crates/brk_core/src/structs/outputtypeindex.rs index ee569fb23..e5a302b6d 100644 --- a/crates/brk_core/src/structs/outputtypeindex.rs +++ b/crates/brk_core/src/structs/outputtypeindex.rs @@ -5,7 +5,7 @@ use derive_deref::{Deref, DerefMut}; use serde::Serialize; use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; -use crate::Error; +use crate::{CheckedSub, Error}; #[derive( Debug, @@ -132,6 +132,11 @@ impl Add for EmptyOutputIndex { Self(*self + rhs) } } +impl CheckedSub for EmptyOutputIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -172,6 +177,11 @@ impl Add for P2MSIndex { Self(*self + rhs) } } +impl CheckedSub for P2MSIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -212,6 +222,11 @@ impl Add for P2AIndex { Self(*self + rhs) } } +impl CheckedSub for P2AIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -252,6 +267,11 @@ impl Add for OpReturnIndex { Self(*self + rhs) } } +impl CheckedSub for OpReturnIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -292,6 +312,11 @@ impl Add for UnknownOutputIndex { Self(*self + rhs) } } +impl CheckedSub for UnknownOutputIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -332,6 +357,11 @@ impl Add for P2PK33Index { Self(*self + rhs) } } +impl CheckedSub for P2PK33Index { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -372,6 +402,11 @@ impl Add for P2PK65Index { Self(*self + rhs) } } +impl CheckedSub for P2PK65Index { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -412,6 +447,11 @@ impl Add for P2PKHIndex { Self(*self + rhs) } } +impl CheckedSub for P2PKHIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -452,6 +492,11 @@ impl Add for P2SHIndex { Self(*self + rhs) } } +impl CheckedSub for P2SHIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -492,6 +537,11 @@ impl Add for P2TRIndex { Self(*self + rhs) } } +impl CheckedSub for P2TRIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -532,6 +582,11 @@ impl Add for P2WPKHIndex { Self(*self + rhs) } } +impl CheckedSub for P2WPKHIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} #[derive( Debug, @@ -572,3 +627,8 @@ impl Add for P2WSHIndex { Self(*self + rhs) } } +impl CheckedSub for P2WSHIndex { + fn checked_sub(self, rhs: Self) -> Option { + self.0.0.checked_sub(rhs.0.0).map(OutputTypeIndex).map(Self) + } +} diff --git a/crates/brk_core/src/structs/stored_u32.rs b/crates/brk_core/src/structs/stored_u32.rs index bebbafb94..c656e5863 100644 --- a/crates/brk_core/src/structs/stored_u32.rs +++ b/crates/brk_core/src/structs/stored_u32.rs @@ -6,6 +6,11 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; use crate::CheckedSub; +use super::{ + EmptyOutputIndex, OpReturnIndex, P2AIndex, P2MSIndex, P2PK33Index, P2PK65Index, P2PKHIndex, + P2SHIndex, P2TRIndex, P2WPKHIndex, P2WSHIndex, UnknownOutputIndex, +}; + #[derive( Debug, Deref, @@ -86,3 +91,75 @@ impl From for usize { value.0 as usize } } + +impl From for StoredU32 { + fn from(value: P2PK65Index) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2PK33Index) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2PKHIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: OpReturnIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2MSIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2SHIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2WSHIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2WPKHIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2TRIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: P2AIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: UnknownOutputIndex) -> Self { + Self::from(usize::from(value)) + } +} + +impl From for StoredU32 { + fn from(value: EmptyOutputIndex) -> Self { + Self::from(usize::from(value)) + } +} diff --git a/crates/brk_indexer/src/stores/mod.rs b/crates/brk_indexer/src/stores/mod.rs index 43f4f4978..c12e15268 100644 --- a/crates/brk_indexer/src/stores/mod.rs +++ b/crates/brk_indexer/src/stores/mod.rs @@ -4,7 +4,7 @@ use brk_core::{ AddressBytes, AddressBytesHash, BlockHashPrefix, Height, OutputType, OutputTypeIndex, TxIndex, TxidPrefix, }; -use brk_vec::{Value, Version}; +use brk_vec::{StoredIndex, Value, Version}; use fjall::{PersistMode, TransactionalKeyspace}; use crate::Indexes; @@ -88,11 +88,12 @@ impl Stores { if starting_indexes.height != Height::ZERO { vecs.height_to_blockhash - .iter_from(starting_indexes.height, |(_, blockhash, ..)| { - let blockhashprefix = BlockHashPrefix::from(blockhash); + .into_iter() + .skip(starting_indexes.height.unwrap_to_usize()) + .for_each(|(_, v)| { + let blockhashprefix = BlockHashPrefix::from(Value::into_inner(v)); self.blockhashprefix_to_height.remove(blockhashprefix); - Ok(()) - })?; + }); if let Some(mut index) = vecs .height_to_first_p2pk65index @@ -234,8 +235,10 @@ impl Stores { if starting_indexes.txindex != TxIndex::ZERO { vecs.txindex_to_txid - .iter_from(starting_indexes.txindex, |(txindex, txid, ..)| { - let txidprefix = TxidPrefix::from(&txid); + .into_iter() + .skip(starting_indexes.txindex.unwrap_to_usize()) + .for_each(|(txindex, txid)| { + let txidprefix = TxidPrefix::from(&txid.into_inner()); // "d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599" let is_not_first_dup = txindex != TxIndex::new(142783) @@ -248,9 +251,7 @@ impl Stores { if is_not_first_dup && is_not_second_dup { self.txidprefix_to_txindex.remove(txidprefix); } - - Ok(()) - })?; + }); } else { self.txidprefix_to_txindex.reset_partition()?; } diff --git a/crates/brk_indexer/src/vecs/base.rs b/crates/brk_indexer/src/vecs/base.rs index 6106ac10a..5ea19c4c2 100644 --- a/crates/brk_indexer/src/vecs/base.rs +++ b/crates/brk_indexer/src/vecs/base.rs @@ -5,8 +5,8 @@ use std::{ }; use brk_vec::{ - Compressed, DynamicVec, Error, GenericVec, Result, StoredIndex, StoredType, StoredVec, Value, - Version, + Compressed, DynamicVec, Error, GenericVec, Result, StoredIndex, StoredType, StoredVec, + StoredVecIterator, Value, Version, }; use super::Height; @@ -54,13 +54,6 @@ where self.inner.double_unwrap_cached_get(index) } - pub fn iter_from(&mut self, index: I, f: F) -> Result<()> - where - F: FnMut((I, T, &mut dyn DynamicVec)) -> Result<()>, - { - self.inner.iter_from(index, f) - } - #[inline] pub fn push_if_needed(&mut self, index: I, value: T) -> Result<()> { match self.inner.len().cmp(&index.to_usize()?) { @@ -127,6 +120,10 @@ where fn path_height_(path: &Path) -> PathBuf { path.join("height") } + + pub fn iter(&self) -> StoredVecIterator<'_, I, T> { + self.into_iter() + } } pub trait AnyIndexedVec: Send + Sync { @@ -147,3 +144,16 @@ where self.flush(height) } } + +impl<'a, I, T> IntoIterator for &'a IndexedVec +where + I: StoredIndex, + T: StoredType, +{ + type Item = (I, Value<'a, T>); + type IntoIter = StoredVecIterator<'a, I, T>; + + fn into_iter(self) -> Self::IntoIter { + self.inner.into_iter() + } +} diff --git a/crates/brk_vec/examples/main.rs b/crates/brk_vec/examples/main.rs index c81b15234..646715a03 100644 --- a/crates/brk_vec/examples/main.rs +++ b/crates/brk_vec/examples/main.rs @@ -61,22 +61,12 @@ fn main() -> Result<(), Box> { dbg!(vec.get(5)?); dbg!(vec.get(20)?); - vec.iter(|(_, v, ..)| { - dbg!(v); - Ok(()) - })?; - - vec.iter_from(5, |(_, v, ..)| { - dbg!(v); - Ok(()) - })?; - dbg!(vec.collect_signed_range(Some(-5), None)?); vec.push(vec.len() as u32); - dbg!(vec.get_last()); + dbg!(vec.last()?); - dbg!(vec.into_iter().map(|v| v).collect::>()); + dbg!(vec.into_iter().collect::>()); } Ok(()) diff --git a/crates/brk_vec/src/lib.rs b/crates/brk_vec/src/lib.rs index 0dd313592..343d2079e 100644 --- a/crates/brk_vec/src/lib.rs +++ b/crates/brk_vec/src/lib.rs @@ -52,6 +52,10 @@ where Self::Raw(_) => {} } } + + pub fn iter(&self) -> StoredVecIterator<'_, I, T> { + self.into_iter() + } } impl DynamicVec for StoredVec @@ -137,16 +141,6 @@ where I: StoredIndex, T: StoredType, { - fn iter_from(&mut self, index: I, f: F) -> Result<()> - where - F: FnMut((I, T, &mut dyn DynamicVec)) -> Result<()>, - { - match self { - StoredVec::Raw(v) => v.iter_from(index, f), - StoredVec::Compressed(v) => v.iter_from(index, f), - } - } - fn collect_range(&self, from: Option, to: Option) -> Result> { match self { StoredVec::Raw(v) => v.collect_range(from, to), @@ -250,6 +244,25 @@ where Compressed(CompressedVecIterator<'a, I, T>), } +impl<'a, I, T> StoredVecIterator<'a, I, T> +where + I: StoredIndex, + T: StoredType, +{ + pub fn get(&mut self, i: usize) -> Option<(I, Value<'a, T>)> { + match self { + Self::Compressed(iter) => { + iter.set(i); + iter.next() + } + Self::Raw(iter) => { + iter.set(i); + iter.next() + } + } + } +} + impl<'a, I, T> Iterator for StoredVecIterator<'a, I, T> where I: StoredIndex, diff --git a/crates/brk_vec/src/traits/dynamic.rs b/crates/brk_vec/src/traits/dynamic.rs index d18282c54..dc50264f9 100644 --- a/crates/brk_vec/src/traits/dynamic.rs +++ b/crates/brk_vec/src/traits/dynamic.rs @@ -45,7 +45,7 @@ pub trait DynamicVec: Send + Sync { .map(Value::Owned)) } fn get_stored_(&self, index: usize, mmap: &Mmap) -> Result>; - fn get_last(&self) -> Result>> { + fn last(&self) -> Result>> { let len = self.len(); if len == 0 { return Ok(None); diff --git a/crates/brk_vec/src/traits/generic.rs b/crates/brk_vec/src/traits/generic.rs index 212489e4f..9519c7c74 100644 --- a/crates/brk_vec/src/traits/generic.rs +++ b/crates/brk_vec/src/traits/generic.rs @@ -98,30 +98,6 @@ where Self::I::to_string() } - #[inline] - fn iter(&mut self, f: F) -> Result<()> - where - F: FnMut( - ( - Self::I, - Self::T, - &mut dyn DynamicVec, - ), - ) -> Result<()>, - { - self.iter_from(Self::I::default(), f) - } - - fn iter_from(&mut self, index: Self::I, f: F) -> Result<()> - where - F: FnMut( - ( - Self::I, - Self::T, - &mut dyn DynamicVec, - ), - ) -> Result<()>; - fn flush(&mut self) -> Result<()>; fn truncate_if_needed(&mut self, index: Self::I) -> Result<()>; diff --git a/crates/brk_vec/src/variants/compressed.rs b/crates/brk_vec/src/variants/compressed.rs index d5cf2b50e..5e74ab774 100644 --- a/crates/brk_vec/src/variants/compressed.rs +++ b/crates/brk_vec/src/variants/compressed.rs @@ -201,6 +201,10 @@ where 0 } } + + pub fn iter(&self) -> CompressedVecIterator<'_, I, T> { + self.into_iter() + } } impl DynamicVec for CompressedVec @@ -293,37 +297,6 @@ where I: StoredIndex, T: StoredType, { - fn iter_from(&mut self, index: I, mut f: F) -> Result<()> - where - F: FnMut((I, T, &mut dyn DynamicVec)) -> Result<()>, - { - if !self.is_pushed_empty() { - return Err(Error::UnsupportedUnflushedState); - } - - let start = index.to_usize()?; - - let stored_len = self.stored_len(); - if start >= stored_len { - return Ok(()); - } - - let mmap = self.mmap().load(); - let pages_meta = self.pages_meta.load(); - - (start..stored_len).try_for_each(|index| { - let v = Self::cached_get_stored__( - index, - &mmap, - stored_len, - &mut self.decoded_page, - &pages_meta, - )? - .unwrap(); - f((I::from(index), v, self as &mut dyn DynamicVec)) - }) - } - fn collect_range(&self, from: Option, to: Option) -> Result> { let stored_len = self.stored_len(); let from = from.unwrap_or_default(); @@ -530,6 +503,12 @@ pub struct CompressedVecIterator<'a, I, T> { index: usize, } +impl CompressedVecIterator<'_, I, T> { + pub fn set(&mut self, i: usize) { + self.index = i + } +} + impl<'a, I, T> Iterator for CompressedVecIterator<'a, I, T> where I: StoredIndex, diff --git a/crates/brk_vec/src/variants/raw.rs b/crates/brk_vec/src/variants/raw.rs index c367e8a6d..fd1968d24 100644 --- a/crates/brk_vec/src/variants/raw.rs +++ b/crates/brk_vec/src/variants/raw.rs @@ -62,6 +62,10 @@ where phantom: PhantomData, }) } + + pub fn iter(&self) -> RawVecIterator<'_, I, T> { + self.into_iter() + } } impl DynamicVec for RawVec @@ -128,29 +132,6 @@ where I: StoredIndex, T: StoredType, { - fn iter_from(&mut self, index: I, mut f: F) -> Result<()> - where - F: FnMut((I, T, &mut dyn DynamicVec)) -> Result<()>, - { - if !self.is_pushed_empty() { - return Err(Error::UnsupportedUnflushedState); - } - - let start = index.to_usize()?; - - let stored_len = self.stored_len(); - if start >= stored_len { - return Ok(()); - } - - let guard = self.mmap.load(); - - (start..stored_len).try_for_each(|index| { - let v = self.get_stored_(index, &guard)?.unwrap(); - f((I::from(index), v, self as &mut dyn DynamicVec)) - }) - } - fn collect_range(&self, from: Option, to: Option) -> Result> { let stored_len = self.stored_len(); let from = from.unwrap_or_default(); @@ -247,6 +228,10 @@ pub struct RawVecIterator<'a, I, T> { impl RawVecIterator<'_, I, T> { const SIZE_OF_T: usize = size_of::(); + + pub fn set(&mut self, i: usize) { + self.index = i + } } impl<'a, I, T> Iterator for RawVecIterator<'a, I, T> diff --git a/websites/kibo.money/index.html b/websites/kibo.money/index.html index f23778541..5bdae76f6 100644 --- a/websites/kibo.money/index.html +++ b/websites/kibo.money/index.html @@ -899,7 +899,7 @@ left: 0; top: 0; bottom: 0; - z-index: 30; + z-index: 40 !important; pointer-events: none; } .shadow-right { diff --git a/websites/kibo.money/scripts/options.js b/websites/kibo.money/scripts/options.js index 0b2c8852f..e77069cdb 100644 --- a/websites/kibo.money/scripts/options.js +++ b/websites/kibo.money/scripts/options.js @@ -356,163 +356,182 @@ function createPartialOptions(colors) { { name: "Transaction", tree: [ - // { - // name: "Count", - // title: "Transaction Count", - // bottom: createBaseAverageSumTotalMinMaxPercentilesSeries({ - // key: "tx-count", - // name: "Count", - // }), - // }, - // { - // name: "Subsidy", - // title: "Subsidy", - // bottom: [ - // ...createBaseAverageSumTotalMinMaxPercentilesSeries({ - // key: "subsidy", - // name: "Subsidy", - // }), - // ...createBaseAverageSumTotalMinMaxPercentilesSeries({ - // key: "subsidy-in-btc", - // name: "Subsidy", - // }), - // ...createBaseAverageSumTotalMinMaxPercentilesSeries({ - // key: "subsidy-in-usd", - // name: "Subsidy", - // }), - // ], - // }, - // { - // name: "Coinbase", - // title: "Coinbase", - // bottom: [ - // ...createBaseAverageSumTotalMinMaxPercentilesSeries({ - // key: "coinbase", - // name: "Coinbase", - // }), - // ...createBaseAverageSumTotalMinMaxPercentilesSeries({ - // key: "coinbase-in-btc", - // name: "Coinbase", - // }), - // ...createBaseAverageSumTotalMinMaxPercentilesSeries({ - // key: "coinbase-in-usd", - // name: "Coinbase", - // }), - // ], - // }, - // { - // name: "Fee", - // title: "Transaction Fee", - // bottom: [ - // ...createAverageSumTotalMinMaxPercentilesSeries("fee"), - // ...createAverageSumTotalMinMaxPercentilesSeries("fee-in-btc"), - // ...createAverageSumTotalMinMaxPercentilesSeries("fee-in-usd"), - // ], - // }, - // { - // name: "Feerate", - // title: "Transaction Fee Rate", - // bottom: [ - // createAverageSeries({ concat: "feerate" }), - // ...createMinMaxPercentilesSeries({ - // concat: "feerate", - // }), - // ], - // }, - // { - // name: "Weight", - // title: "Transaction Weight", - // bottom: [ - // createAverageSeries({ concat: "tx-weight" }), - // ...createMinMaxPercentilesSeries({ - // concat: "tx-weight", - // }), - // ], - // }, - // { - // name: "vsize", - // title: "Transaction Virtual Size", - // bottom: [ - // createAverageSeries({ concat: "tx-vsize" }), - // ...createMinMaxPercentilesSeries({ - // concat: "tx-vsize", - // }), - // ], - // }, - // { - // name: "Versions", - // title: "Transaction Versions", - // bottom: [ - // createBaseSeries({ - // key: "tx-v1", - // name: "v1 Count", - // }), - // ...createSumTotalSeries({ concat: "tx-v1", name: "v1" }), - // createBaseSeries({ - // key: "tx-v2", - // name: "v2 Count", - // }), - // ...createSumTotalSeries({ concat: "tx-v2", name: "v2" }), - // createBaseSeries({ - // key: "tx-v3", - // name: "v3 Count", - // }), - // ...createSumTotalSeries({ concat: "tx-v3", name: "v3" }), - // ], - // }, + { + name: "Count", + title: "Transaction Count", + bottom: createBaseAverageSumTotalMinMaxPercentilesSeries({ + key: "tx-count", + name: "Count", + }), + }, + { + name: "Subsidy", + title: "Subsidy", + bottom: [ + ...createBaseAverageSumTotalMinMaxPercentilesSeries({ + key: "subsidy", + name: "Subsidy", + }), + ...createBaseAverageSumTotalMinMaxPercentilesSeries({ + key: "subsidy-in-btc", + name: "Subsidy", + }), + ...createBaseAverageSumTotalMinMaxPercentilesSeries({ + key: "subsidy-in-usd", + name: "Subsidy", + }), + ], + }, + { + name: "Coinbase", + title: "Coinbase", + bottom: [ + ...createBaseAverageSumTotalMinMaxPercentilesSeries({ + key: "coinbase", + name: "Coinbase", + }), + ...createBaseAverageSumTotalMinMaxPercentilesSeries({ + key: "coinbase-in-btc", + name: "Coinbase", + }), + ...createBaseAverageSumTotalMinMaxPercentilesSeries({ + key: "coinbase-in-usd", + name: "Coinbase", + }), + ], + }, + { + name: "Fee", + title: "Transaction Fee", + bottom: [ + ...createAverageSumTotalMinMaxPercentilesSeries("fee"), + ...createAverageSumTotalMinMaxPercentilesSeries("fee-in-btc"), + ...createAverageSumTotalMinMaxPercentilesSeries("fee-in-usd"), + ], + }, + { + name: "Feerate", + title: "Transaction Fee Rate", + bottom: [ + createAverageSeries({ concat: "feerate" }), + ...createMinMaxPercentilesSeries({ + concat: "feerate", + }), + ], + }, + { + name: "Weight", + title: "Transaction Weight", + bottom: [ + createAverageSeries({ concat: "tx-weight" }), + ...createMinMaxPercentilesSeries({ + concat: "tx-weight", + }), + ], + }, + { + name: "vsize", + title: "Transaction Virtual Size", + bottom: [ + createAverageSeries({ concat: "tx-vsize" }), + ...createMinMaxPercentilesSeries({ + concat: "tx-vsize", + }), + ], + }, + { + name: "Versions", + title: "Transaction Versions", + bottom: [ + createBaseSeries({ + key: "tx-v1", + name: "v1 Count", + }), + ...createSumTotalSeries({ concat: "tx-v1", name: "v1" }), + createBaseSeries({ + key: "tx-v2", + name: "v2 Count", + }), + ...createSumTotalSeries({ concat: "tx-v2", name: "v2" }), + createBaseSeries({ + key: "tx-v3", + name: "v3 Count", + }), + ...createSumTotalSeries({ concat: "tx-v3", name: "v3" }), + ], + }, ], }, { name: "Input", tree: [ - // { - // name: "Count", - // title: "Transaction Input Count", - // bottom: [ - // createAverageSeries({ concat: "input-count" }), - // ...createSumTotalSeries({ concat: "input-count" }), - // ...createMinMaxPercentilesSeries({ - // concat: "input-count", - // }), - // ], - // }, - // { - // name: "Value", - // title: "Transaction Input Value", - // bottom: [ - // createAverageSeries({ concat: "input-value" }), - // ...createSumTotalSeries({ concat: "input-value" }), - // ], - // }, + { + name: "Count", + title: "Transaction Input Count", + bottom: [ + createAverageSeries({ concat: "input-count" }), + ...createSumTotalSeries({ concat: "input-count" }), + ...createMinMaxPercentilesSeries({ + concat: "input-count", + }), + ], + }, + { + name: "Value", + title: "Transaction Input Value", + bottom: [ + createAverageSeries({ concat: "input-value" }), + ...createSumTotalSeries({ concat: "input-value" }), + ], + }, ], }, { name: "Output", tree: [ - // { - // name: "Count", - // title: "Transaction Output Count", - // bottom: [ - // createAverageSeries({ concat: "output-count" }), - // ...createSumTotalSeries({ concat: "output-count" }), - // ...createMinMaxPercentilesSeries({ - // concat: "output-count", - // }), - // ], - // }, - // { - // name: "Value", - // title: "Transaction Output Value", - // bottom: [ - // createAverageSeries({ concat: "output-value" }), - // ...createSumTotalSeries({ concat: "output-value" }), - // ], - // }, + { + name: "Count", + title: "Transaction Output Count", + bottom: [ + createAverageSeries({ concat: "output-count" }), + ...createSumTotalSeries({ concat: "output-count" }), + ...createMinMaxPercentilesSeries({ + concat: "output-count", + }), + ], + }, + { + name: "Value", + title: "Transaction Output Value", + bottom: [ + createAverageSeries({ concat: "output-value" }), + ...createSumTotalSeries({ concat: "output-value" }), + ], + }, + { + name: "By type", + tree: [], + // title: "Transaction Output Value", + // bottom: [ + // createAverageSeries({ concat: "output-value" }), + // ...createSumTotalSeries({ concat: "output-value" }), + // ], + }, ], }, { name: "Mining", tree: [ + { + name: "Supply", + title: "Circulating Supply", + bottom: [ + createBaseSeries({ + key: "total-subsidy-in-btc", + name: "Supply", + }), + ], + }, { name: "Difficulty", title: "Difficulty", diff --git a/websites/kibo.money/scripts/vecid-to-indexes.js b/websites/kibo.money/scripts/vecid-to-indexes.js index febe07bca..20d98a799 100644 --- a/websites/kibo.money/scripts/vecid-to-indexes.js +++ b/websites/kibo.money/scripts/vecid-to-indexes.js @@ -74,13 +74,92 @@ export function createVecIdToIndexes() { close: [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "close-in-cents": [DateIndex, Height], "close-in-sats": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + coinbase: [Height], + "coinbase-10p": [DateIndex], + "coinbase-25p": [DateIndex], + "coinbase-75p": [DateIndex], + "coinbase-90p": [DateIndex], + "coinbase-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-btc": [Height], + "coinbase-in-btc-10p": [DateIndex], + "coinbase-in-btc-25p": [DateIndex], + "coinbase-in-btc-75p": [DateIndex], + "coinbase-in-btc-90p": [DateIndex], + "coinbase-in-btc-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-btc-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-btc-median": [DateIndex], + "coinbase-in-btc-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-btc-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-usd": [Height], + "coinbase-in-usd-10p": [DateIndex], + "coinbase-in-usd-25p": [DateIndex], + "coinbase-in-usd-75p": [DateIndex], + "coinbase-in-usd-90p": [DateIndex], + "coinbase-in-usd-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-usd-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-usd-median": [DateIndex], + "coinbase-in-usd-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-in-usd-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-median": [DateIndex], + "coinbase-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "coinbase-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], date: [DateIndex, Height], "date-fixed": [Height], dateindex: [DateIndex, Height], decadeindex: [DecadeIndex, YearIndex], difficulty: [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], difficultyepoch: [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "emptyoutput-count": [Height], + "emptyoutput-count-10p": [DateIndex], + "emptyoutput-count-25p": [DateIndex], + "emptyoutput-count-75p": [DateIndex], + "emptyoutput-count-90p": [DateIndex], + "emptyoutput-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "emptyoutput-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "emptyoutput-count-median": [DateIndex], + "emptyoutput-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "emptyoutput-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], emptyoutputindex: [EmptyOutputIndex], + fee: [TxIndex], + "fee-10p": [Height], + "fee-25p": [Height], + "fee-75p": [Height], + "fee-90p": [Height], + "fee-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-btc": [TxIndex], + "fee-in-btc-10p": [Height], + "fee-in-btc-25p": [Height], + "fee-in-btc-75p": [Height], + "fee-in-btc-90p": [Height], + "fee-in-btc-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-btc-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-btc-median": [Height], + "fee-in-btc-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-btc-sum": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-usd": [TxIndex], + "fee-in-usd-10p": [Height], + "fee-in-usd-25p": [Height], + "fee-in-usd-75p": [Height], + "fee-in-usd-90p": [Height], + "fee-in-usd-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-usd-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-usd-median": [Height], + "fee-in-usd-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-in-usd-sum": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-median": [Height], + "fee-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "fee-sum": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + feerate: [TxIndex], + "feerate-10p": [Height], + "feerate-25p": [Height], + "feerate-75p": [Height], + "feerate-90p": [Height], + "feerate-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "feerate-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "feerate-median": [Height], + "feerate-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "first-dateindex": [MonthIndex, WeekIndex], "first-emptyoutputindex": [Height], "first-height": [DateIndex, DifficultyEpoch, HalvingEpoch], @@ -105,15 +184,41 @@ export function createVecIdToIndexes() { high: [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "high-in-cents": [DateIndex, Height], "high-in-sats": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "input-count": [TxIndex], + "input-count-10p": [Height], + "input-count-25p": [Height], + "input-count-75p": [Height], + "input-count-90p": [Height], + "input-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "input-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "input-count-median": [Height], + "input-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "input-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "input-value": [TxIndex], + "input-value-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "input-value-sum": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], inputindex: [InputIndex], interval: [Height], + "is-coinbase": [TxIndex], "is-explicitly-rbf": [TxIndex], "last-dateindex": [MonthIndex, WeekIndex], + "last-emptyoutputindex": [Height], "last-height": [DateIndex, DifficultyEpoch, HalvingEpoch], "last-inputindex": [TxIndex], "last-monthindex": [QuarterIndex, YearIndex], + "last-opreturnindex": [Height], "last-outputindex": [TxIndex], + "last-p2aindex": [Height], + "last-p2msindex": [Height], + "last-p2pk33index": [Height], + "last-p2pk65index": [Height], + "last-p2pkhindex": [Height], + "last-p2shindex": [Height], + "last-p2trindex": [Height], + "last-p2wpkhindex": [Height], + "last-p2wshindex": [Height], "last-txindex": [Height], + "last-unknownoutputindex": [Height], "last-yearindex": [DecadeIndex], low: [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "low-in-cents": [DateIndex, Height], @@ -125,44 +230,259 @@ export function createVecIdToIndexes() { open: [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "open-in-cents": [DateIndex, Height], "open-in-sats": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "opreturn-count": [Height], + "opreturn-count-10p": [DateIndex], + "opreturn-count-25p": [DateIndex], + "opreturn-count-75p": [DateIndex], + "opreturn-count-90p": [DateIndex], + "opreturn-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "opreturn-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "opreturn-count-median": [DateIndex], + "opreturn-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "opreturn-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], opreturnindex: [OpReturnIndex], + "output-count": [TxIndex], + "output-count-10p": [Height], + "output-count-25p": [Height], + "output-count-75p": [Height], + "output-count-90p": [Height], + "output-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "output-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "output-count-median": [Height], + "output-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "output-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "output-value": [TxIndex], + "output-value-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "output-value-sum": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], outputindex: [InputIndex, OutputIndex], outputtype: [OutputIndex], outputtypeindex: [OutputIndex], + "p2a-count": [Height], + "p2a-count-10p": [DateIndex], + "p2a-count-25p": [DateIndex], + "p2a-count-75p": [DateIndex], + "p2a-count-90p": [DateIndex], + "p2a-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2a-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2a-count-median": [DateIndex], + "p2a-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2a-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2abytes: [P2AIndex], p2aindex: [P2AIndex], + "p2ms-count": [Height], + "p2ms-count-10p": [DateIndex], + "p2ms-count-25p": [DateIndex], + "p2ms-count-75p": [DateIndex], + "p2ms-count-90p": [DateIndex], + "p2ms-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2ms-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2ms-count-median": [DateIndex], + "p2ms-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2ms-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2msindex: [P2MSIndex], + "p2pk33-count": [Height], + "p2pk33-count-10p": [DateIndex], + "p2pk33-count-25p": [DateIndex], + "p2pk33-count-75p": [DateIndex], + "p2pk33-count-90p": [DateIndex], + "p2pk33-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pk33-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pk33-count-median": [DateIndex], + "p2pk33-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pk33-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2pk33bytes: [P2PK33Index], p2pk33index: [P2PK33Index], + "p2pk65-count": [Height], + "p2pk65-count-10p": [DateIndex], + "p2pk65-count-25p": [DateIndex], + "p2pk65-count-75p": [DateIndex], + "p2pk65-count-90p": [DateIndex], + "p2pk65-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pk65-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pk65-count-median": [DateIndex], + "p2pk65-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pk65-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2pk65bytes: [P2PK65Index], p2pk65index: [P2PK65Index], + "p2pkh-count": [Height], + "p2pkh-count-10p": [DateIndex], + "p2pkh-count-25p": [DateIndex], + "p2pkh-count-75p": [DateIndex], + "p2pkh-count-90p": [DateIndex], + "p2pkh-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pkh-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pkh-count-median": [DateIndex], + "p2pkh-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2pkh-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2pkhbytes: [P2PKHIndex], p2pkhindex: [P2PKHIndex], + "p2sh-count": [Height], + "p2sh-count-10p": [DateIndex], + "p2sh-count-25p": [DateIndex], + "p2sh-count-75p": [DateIndex], + "p2sh-count-90p": [DateIndex], + "p2sh-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2sh-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2sh-count-median": [DateIndex], + "p2sh-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2sh-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2shbytes: [P2SHIndex], p2shindex: [P2SHIndex], + "p2tr-count": [Height], + "p2tr-count-10p": [DateIndex], + "p2tr-count-25p": [DateIndex], + "p2tr-count-75p": [DateIndex], + "p2tr-count-90p": [DateIndex], + "p2tr-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2tr-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2tr-count-median": [DateIndex], + "p2tr-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2tr-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2trbytes: [P2TRIndex], p2trindex: [P2TRIndex], + "p2wpkh-count": [Height], + "p2wpkh-count-10p": [DateIndex], + "p2wpkh-count-25p": [DateIndex], + "p2wpkh-count-75p": [DateIndex], + "p2wpkh-count-90p": [DateIndex], + "p2wpkh-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2wpkh-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2wpkh-count-median": [DateIndex], + "p2wpkh-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2wpkh-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2wpkhbytes: [P2WPKHIndex], p2wpkhindex: [P2WPKHIndex], + "p2wsh-count": [Height], + "p2wsh-count-10p": [DateIndex], + "p2wsh-count-25p": [DateIndex], + "p2wsh-count-75p": [DateIndex], + "p2wsh-count-90p": [DateIndex], + "p2wsh-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2wsh-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2wsh-count-median": [DateIndex], + "p2wsh-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "p2wsh-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], p2wshbytes: [P2WSHIndex], p2wshindex: [P2WSHIndex], quarterindex: [MonthIndex, QuarterIndex], rawlocktime: [TxIndex], + subsidy: [Height], + "subsidy-10p": [DateIndex], + "subsidy-25p": [DateIndex], + "subsidy-75p": [DateIndex], + "subsidy-90p": [DateIndex], + "subsidy-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-btc": [Height], + "subsidy-in-btc-10p": [DateIndex], + "subsidy-in-btc-25p": [DateIndex], + "subsidy-in-btc-75p": [DateIndex], + "subsidy-in-btc-90p": [DateIndex], + "subsidy-in-btc-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-btc-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-btc-median": [DateIndex], + "subsidy-in-btc-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-btc-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-usd": [Height], + "subsidy-in-usd-10p": [DateIndex], + "subsidy-in-usd-25p": [DateIndex], + "subsidy-in-usd-75p": [DateIndex], + "subsidy-in-usd-90p": [DateIndex], + "subsidy-in-usd-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-usd-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-usd-median": [DateIndex], + "subsidy-in-usd-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-in-usd-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-median": [DateIndex], + "subsidy-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "subsidy-sum": [DateIndex, DecadeIndex, DifficultyEpoch, 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], "total-block-size": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "total-block-vbytes": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "total-block-weight": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-coinbase": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-coinbase-in-btc": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-coinbase-in-usd": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-emptyoutput-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-fee": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-fee-in-btc": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-fee-in-usd": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-input-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-input-value": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-opreturn-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-output-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-output-value": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2a-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2ms-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2pk33-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2pk65-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2pkh-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2sh-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2tr-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2wpkh-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-p2wsh-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], "total-size": [Height, TxIndex], + "total-subsidy": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-subsidy-in-btc": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-subsidy-in-usd": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-tx-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-tx-v1": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-tx-v2": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-tx-v3": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "total-unknownoutput-count": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-count": [Height], + "tx-count-10p": [DateIndex], + "tx-count-25p": [DateIndex], + "tx-count-75p": [DateIndex], + "tx-count-90p": [DateIndex], + "tx-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-count-median": [DateIndex], + "tx-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-v1": [Height], + "tx-v1-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-v2": [Height], + "tx-v2-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-v3": [Height], + "tx-v3-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-vsize-10p": [Height], + "tx-vsize-25p": [Height], + "tx-vsize-75p": [Height], + "tx-vsize-90p": [Height], + "tx-vsize-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-vsize-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-vsize-median": [Height], + "tx-vsize-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-weight-10p": [Height], + "tx-weight-25p": [Height], + "tx-weight-75p": [Height], + "tx-weight-90p": [Height], + "tx-weight-average": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-weight-max": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "tx-weight-median": [Height], + "tx-weight-min": [DateIndex, DecadeIndex, DifficultyEpoch, Height, MonthIndex, QuarterIndex, WeekIndex, YearIndex], txid: [TxIndex], txindex: [EmptyOutputIndex, OpReturnIndex, P2MSIndex, TxIndex, UnknownOutputIndex], txversion: [TxIndex], + "unknownoutput-count": [Height], + "unknownoutput-count-10p": [DateIndex], + "unknownoutput-count-25p": [DateIndex], + "unknownoutput-count-75p": [DateIndex], + "unknownoutput-count-90p": [DateIndex], + "unknownoutput-count-average": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "unknownoutput-count-max": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "unknownoutput-count-median": [DateIndex], + "unknownoutput-count-min": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], + "unknownoutput-count-sum": [DateIndex, DecadeIndex, DifficultyEpoch, MonthIndex, QuarterIndex, WeekIndex, YearIndex], unknownoutputindex: [UnknownOutputIndex], - value: [OutputIndex], + value: [InputIndex, OutputIndex], vbytes: [Height], + vsize: [TxIndex], weekindex: [DateIndex, WeekIndex], - weight: [Height], + weight: [Height, TxIndex], yearindex: [MonthIndex, YearIndex], }); }