diff --git a/CHANGELOG.md b/CHANGELOG.md index eee1fa891..354e33558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ Added git tags for each version though Markdown won't display formatted on Githu Moved Sanakirja database wrapper to its own crate (`snkrj`) and added a robust auto defragmentation to improve disk usage without the need for user's intervention. Since it's not used anymore it will moved out of the repository relatively soon. -# [v0.5.0](https://github.com/kibo-money/kibo/tree/eea56d394bf92c62c81da8b78b8c47ea730683f5) | [873199](https://mempool.space/block/0000000000000000000270925aa6a565be92e13164565a3f7994ca1966e48050) - 2024/12/04 +# [kibo-v0.5.0](https://github.com/kibo-money/kibo/tree/eea56d394bf92c62c81da8b78b8c47ea730683f5) | [873199](https://mempool.space/block/0000000000000000000270925aa6a565be92e13164565a3f7994ca1966e48050) - 2024/12/04 ![Image of the kibo Web App version 0.5.0](https://github.com/kibo-money/kibo/blob/main/_assets/v0.5.0.jpg) @@ -103,7 +103,7 @@ Since it's not used anymore it will moved out of the repository relatively soon. - Moved back to this repo -# [v0.4.0](https://github.com/kibo-money/kibo/tree/a64c544815d9ef785e2fc1323582f774f16b9200) | [861950](https://mempool.space/block/00000000000000000000530d0e30ccf7deeace122dcc99f2668a06c6dad83629) - 2024/09/19 +# [kibo-v0.4.0](https://github.com/kibo-money/kibo/tree/a64c544815d9ef785e2fc1323582f774f16b9200) | [861950](https://mempool.space/block/00000000000000000000530d0e30ccf7deeace122dcc99f2668a06c6dad83629) - 2024/09/19 ![Image of the kibo Web App version 0.4.0](https://github.com/kibo-money/kibo/blob/main/_assets/v0.4.0.jpg) @@ -140,7 +140,7 @@ Since it's not used anymore it will moved out of the repository relatively soon. - Added serving of the website - Improved `Cache-Control` behavior -# [v0.3.0](https://github.com/kibo-money/kibo/tree/b68b016091c45b071218fba01bac5b76e8eaf18c) | [853930](https://mempool.space/block/00000000000000000002eb5e9a7950ca2d5d98bd1ed28fc9098aa630d417985d) - 2024/07/26 +# [kibo-v0.3.0](https://github.com/kibo-money/kibo/tree/b68b016091c45b071218fba01bac5b76e8eaf18c) | [853930](https://mempool.space/block/00000000000000000002eb5e9a7950ca2d5d98bd1ed28fc9098aa630d417985d) - 2024/07/26 ![Image of the Satonomics Web App version 0.3.0](https://github.com/kibo-money/kibo/blob/main/_assets/v0.3.0.jpg) @@ -219,7 +219,7 @@ Since it's not used anymore it will moved out of the repository relatively soon. - Only run with a watcher if `cargo watch` is available - Removed id_to_path file in favor for only `paths.d.ts` in `app/src/types` -# [v0.2.0](https://github.com/kibo-money/kibo/tree/248187889283597c5dbb806292297453c25e97b8) | [851286](https://mempool.space/block/0000000000000000000281ca7f1bf8c50702bfca168c7af1bdc67c977c1ac8ed) - 2024/07/08 +# [kibo-v0.2.0](https://github.com/kibo-money/kibo/tree/248187889283597c5dbb806292297453c25e97b8) | [851286](https://mempool.space/block/0000000000000000000281ca7f1bf8c50702bfca168c7af1bdc67c977c1ac8ed) - 2024/07/08 ![Image of the Satonomics Web App version 0.2.0](https://github.com/kibo-money/kibo/blob/main/_assets/v0.2.0.jpg) @@ -255,7 +255,7 @@ Since it's not used anymore it will moved out of the repository relatively soon. - Fixed ulimit only being run in Mac OS instead of whenever the program is detected -# [v0.1.1](https://github.com/kibo-money/kibo/tree/e55b5195a9de9aea306903c94ed63cb1720fda5f) | [849240](https://mempool.space/block/000000000000000000002b8653988655071c07bb5f7181c038f9326bc86db741) - 2024/06/24 +# [kibo-v0.1.1](https://github.com/kibo-money/kibo/tree/e55b5195a9de9aea306903c94ed63cb1720fda5f) | [849240](https://mempool.space/block/000000000000000000002b8653988655071c07bb5f7181c038f9326bc86db741) - 2024/06/24 ![Image of the Satonomics Web App version 0.1.1](https://github.com/kibo-money/kibo/blob/main/_assets/v0.1.1.jpg) @@ -305,10 +305,10 @@ Since it's not used anymore it will moved out of the repository relatively soon. - Deleted old price datasets and their backups -# [v0.1.0](https://github.com/kibo-money/kibo/tree/a1a576d088c8f83ed32d48753a7611f70a964574) | [848642](https://mempool.space/block/000000000000000000020be5761d70751252219a9557f55e91ecdfb86c4e026a) - 2024/06/19 +# [kibo-v0.1.0](https://github.com/kibo-money/kibo/tree/a1a576d088c8f83ed32d48753a7611f70a964574) | [848642](https://mempool.space/block/000000000000000000020be5761d70751252219a9557f55e91ecdfb86c4e026a) - 2024/06/19 ![Image of the Satonomics Web App version 0.1.0](https://github.com/kibo-money/kibo/blob/main/_assets/v0.1.0.jpg) -# v0.0.1 | [835444](https://mempool.space/block/000000000000000000009f93907a0dd83c080d5585cc7ec82c076d45f6d7c872) - 2024/03/20 +# kibo-v0.0.1 | [835444](https://mempool.space/block/000000000000000000009f93907a0dd83c080d5585cc7ec82c076d45f6d7c872) - 2024/03/20 ![Image of the Satonomics Web App version 0.0.X](https://github.com/kibo-money/kibo/blob/main/_assets/v0.0.X.jpg) diff --git a/Cargo.lock b/Cargo.lock index 5df07d887..f995cee86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -971,9 +971,9 @@ checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b" [[package]] name = "deranged" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", "serde", @@ -2403,9 +2403,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ "bitflags", ] @@ -2915,9 +2915,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.44.1" +version = "1.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 865a5def1..05c9c2df4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,8 @@ zerocopy = { version = "0.8.24", features = ["derive"] } [workspace.metadata.release] shared-version = true tag-name = "v{{version}}" +pre-release-commit-message = "release: v{{version}}" +tag-message = "release: v{{version}}" [workspace.metadata.dist] cargo-dist-version = "0.28.0" diff --git a/crates/brk_computer/src/storage/vecs/blocks.rs b/crates/brk_computer/src/storage/vecs/blocks.rs index 916dd4ec8..b66007784 100644 --- a/crates/brk_computer/src/storage/vecs/blocks.rs +++ b/crates/brk_computer/src/storage/vecs/blocks.rs @@ -1,12 +1,12 @@ use std::{fs, path::Path}; -use brk_core::{CheckedSub, Dateindex, Timestamp}; +use brk_core::{CheckedSub, CounterU32, Timestamp}; use brk_exit::Exit; use brk_indexer::Indexer; use brk_vec::{AnyStorableVec, Compressed, Version}; use super::{ - ComputedVec, Indexes, + Indexes, grouped::{ComputedVecsFromHeight, StorableVecGeneatorOptions}, indexes, }; @@ -14,8 +14,7 @@ use super::{ #[derive(Clone)] pub struct Vecs { pub indexes_to_block_interval: ComputedVecsFromHeight, - pub dateindex_to_block_count: ComputedVec, - pub dateindex_to_total_block_count: ComputedVec, + pub indexes_to_block_count: ComputedVecsFromHeight, } impl Vecs { @@ -33,15 +32,12 @@ impl Vecs { .add_minmax() .add_average(), )?, - dateindex_to_block_count: ComputedVec::forced_import( - &path.join("dateindex_to_block_count"), - Version::ONE, - compressed, - )?, - dateindex_to_total_block_count: ComputedVec::forced_import( - &path.join("dateindex_to_total_block_count"), + indexes_to_block_count: ComputedVecsFromHeight::forced_import( + path, + "block_count", Version::ONE, compressed, + StorableVecGeneatorOptions::default().add_sum().add_total(), )?, }) } @@ -53,10 +49,14 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> color_eyre::Result<()> { - let indexer_vecs = indexer.mut_vecs(); - self.indexes_to_block_interval.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, _, starting_indexes, exit| { + let indexer_vecs = indexer.mut_vecs(); + v.compute_transform( starting_indexes.height, indexer_vecs.height_to_timestamp.mut_vec(), @@ -72,9 +72,23 @@ impl Vecs { exit, ) }, + )?; + + self.indexes_to_block_count.compute( + indexer, indexes, starting_indexes, exit, + |v, indexer, _, starting_indexes, exit| { + let indexer_vecs = indexer.mut_vecs(); + + v.compute_transform( + starting_indexes.height, + indexer_vecs.height_to_weight.mut_vec(), + |(h, ..)| (h, CounterU32::from(1_u32)), + exit, + ) + }, )?; Ok(()) @@ -82,11 +96,8 @@ impl Vecs { pub fn as_any_vecs(&self) -> Vec<&dyn AnyStorableVec> { [ - vec![ - self.dateindex_to_block_count.any_vec(), - self.dateindex_to_total_block_count.any_vec(), - ], self.indexes_to_block_interval.any_vecs(), + self.indexes_to_block_count.any_vecs(), ] .concat() } diff --git a/crates/brk_computer/src/storage/vecs/grouped/builder.rs b/crates/brk_computer/src/storage/vecs/grouped/builder.rs index 84c36a02f..db58aed8f 100644 --- a/crates/brk_computer/src/storage/vecs/grouped/builder.rs +++ b/crates/brk_computer/src/storage/vecs/grouped/builder.rs @@ -1,7 +1,7 @@ use std::path::Path; use brk_exit::Exit; -use brk_vec::{AnyStorableVec, Compressed, Result, StoredIndex, StoredType, Version}; +use brk_vec::{AnyStorableVec, Compressed, Result, StorableVec, StoredIndex, StoredType, Version}; use crate::storage::vecs::base::ComputedVec; @@ -24,6 +24,7 @@ where pub _10p: Option>, pub min: Option>, pub last: Option>, + pub total: Option>, } impl ComputedVecBuilder @@ -37,71 +38,119 @@ where compressed: Compressed, options: StorableVecGeneatorOptions, ) -> color_eyre::Result { - // let name = path.file_name().unwrap().to_str().unwrap().to_string(); let key = I::to_string().split("::").last().unwrap().to_lowercase(); let only_one_active = options.is_only_one_active(); - let prefix = |s: &str| { + let default = || path.join(format!("{key}_to_{name}")); + + let prefix = |s: &str| path.join(format!("{key}_to_{s}_{name}")); + + let maybe_prefix = |s: &str| { if only_one_active { - path.with_file_name(format!("{key}_to_{name}")) + default() } else { - path.with_file_name(format!("{key}_to_{s}_{name}")) + prefix(s) } }; - let suffix = |s: &str| { + let suffix = |s: &str| path.join(format!("{key}_to_{name}_{s}")); + + let maybe_suffix = |s: &str| { if only_one_active { - path.with_file_name(format!("{key}_to_{name}")) + default() } else { - path.with_file_name(format!("{key}_to_{name}_{s}")) + suffix(s) } }; let s = Self { first: options.first.then(|| { - ComputedVec::forced_import(&prefix("first"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_prefix("first"), Version::ONE, compressed) + .unwrap() }), last: options.last.then(|| { ComputedVec::forced_import( - &path.with_file_name(format!("{key}_to_{name}")), + &path.join(format!("{key}_to_{name}")), Version::ONE, compressed, ) .unwrap() }), min: options.min.then(|| { - ComputedVec::forced_import(&suffix("min"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("min"), Version::ONE, compressed).unwrap() }), max: options.max.then(|| { - ComputedVec::forced_import(&suffix("max"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("max"), Version::ONE, compressed).unwrap() }), median: options.median.then(|| { - ComputedVec::forced_import(&suffix("median"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("median"), Version::ONE, compressed) + .unwrap() }), average: options.average.then(|| { - ComputedVec::forced_import(&suffix("average"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("average"), Version::ONE, compressed) + .unwrap() }), sum: options.sum.then(|| { - ComputedVec::forced_import(&suffix("sum"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("sum"), Version::ONE, compressed).unwrap() + }), + total: options.total.then(|| { + ComputedVec::forced_import(&prefix("total"), Version::ONE, compressed).unwrap() }), _90p: options._90p.then(|| { - ComputedVec::forced_import(&suffix("90p"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("90p"), Version::ONE, compressed).unwrap() }), _75p: options._75p.then(|| { - ComputedVec::forced_import(&suffix("75p"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("75p"), Version::ONE, compressed).unwrap() }), _25p: options._25p.then(|| { - ComputedVec::forced_import(&suffix("25p"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("25p"), Version::ONE, compressed).unwrap() }), _10p: options._10p.then(|| { - ComputedVec::forced_import(&suffix("10p"), Version::ONE, compressed).unwrap() + ComputedVec::forced_import(&maybe_suffix("10p"), Version::ONE, compressed).unwrap() }), }; Ok(s) } + pub fn extend( + &mut self, + max_from: I, + source: &mut StorableVec, + exit: &Exit, + ) -> Result<()> { + if self.total.is_none() { + return Ok(()); + }; + + let index = self.starting_index(max_from); + + let total_vec = self.total.as_mut().unwrap(); + + source.iter_from(index, |(i, v)| { + let prev = i + .to_usize() + .unwrap() + .checked_sub(1) + .map_or(T::from(0_usize), |prev_i| { + total_vec + .get(I::from(prev_i)) + .unwrap() + .unwrap_or(&T::from(0_usize)) + .to_owned() + }); + let value = v.clone() + prev; + total_vec.forced_push_at(i, value, exit)?; + + Ok(()) + })?; + + self.safe_flush(exit)?; + + Ok(()) + } + pub fn compute( &mut self, max_from: I, @@ -134,7 +183,8 @@ where let first_index = first_index.to_usize()?; let last_index = last_index.to_usize()?; - let needs_sum_or_average = self.sum.is_some() || self.average.is_some(); + 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() @@ -142,7 +192,7 @@ where || self._25p.is_some() || self._10p.is_some() || self.min.is_some(); - let needs_values = needs_sorted || needs_sum_or_average; + let needs_values = needs_sorted || needs_average_sum_or_total; if needs_values { let mut values = @@ -180,7 +230,7 @@ where } } - if needs_sum_or_average { + if needs_average_sum_or_total { let len = values.len(); if let Some(average) = self.average.as_mut() { @@ -193,9 +243,22 @@ where average.forced_push_at(i, avg, exit)?; } - if let Some(sum_vec) = self.sum.as_mut() { + if needs_sum_or_total { let sum = values.into_iter().fold(T::from(0), |a, b| a + b); - sum_vec.forced_push_at(i, sum, exit)?; + + 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.to_usize().unwrap().checked_sub(1).map_or( + T::from(0_usize), + |prev_i| { + total_vec.get(I::from(prev_i)).unwrap().unwrap().to_owned() + }, + ); + total_vec.forced_push_at(i, prev + sum, exit)?; + } } } } @@ -264,9 +327,10 @@ where let first_index = Some(first_index.to_usize()? as i64); let last_index = Some(last_index.to_usize()? as i64); - let needs_sum_or_average = self.sum.is_some() || self.average.is_some(); + 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_sum_or_average; + let needs_values = needs_sorted || needs_average_sum_or_total; if needs_values { if needs_sorted { @@ -291,7 +355,7 @@ where } } - if needs_sum_or_average { + if needs_average_sum_or_total { if let Some(average) = self.average.as_mut() { let values = source .average @@ -309,14 +373,27 @@ where average.forced_push_at(i, avg, exit)?; } - if let Some(sum_vec) = self.sum.as_mut() { + if needs_sum_or_total { let values = source .sum .as_ref() .unwrap() .collect_range(first_index, last_index)?; let sum = values.into_iter().fold(T::from(0), |a, b| a + b); - sum_vec.forced_push_at(i, sum, exit)?; + + 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.to_usize().unwrap().checked_sub(1).map_or( + T::from(0_usize), + |prev_i| { + total_vec.get(I::from(prev_i)).unwrap().unwrap().to_owned() + }, + ); + total_vec.forced_push_at(i, prev + sum, exit)?; + } } } } @@ -381,6 +458,9 @@ where if let Some(sum) = self.sum.as_ref() { v.push(sum.any_vec()); } + if let Some(total) = self.total.as_ref() { + v.push(total.any_vec()); + } if let Some(_90p) = self._90p.as_ref() { v.push(_90p.any_vec()); } @@ -419,6 +499,9 @@ where if let Some(sum) = self.sum.as_mut() { sum.safe_flush(exit)?; } + if let Some(total) = self.total.as_mut() { + total.safe_flush(exit)?; + } if let Some(_90p) = self._90p.as_mut() { _90p.safe_flush(exit)?; } @@ -449,6 +532,7 @@ pub struct StorableVecGeneatorOptions { min: bool, first: bool, last: bool, + total: bool, } impl StorableVecGeneatorOptions { @@ -507,6 +591,11 @@ impl StorableVecGeneatorOptions { self } + pub fn add_total(mut self) -> Self { + self.total = true; + self + } + pub fn rm_min(mut self) -> Self { self.min = false; self @@ -552,6 +641,11 @@ impl StorableVecGeneatorOptions { self } + pub fn rm_total(mut self) -> Self { + self.total = false; + self + } + pub fn add_minmax(mut self) -> Self { self.min = true; self.max = true; @@ -589,10 +683,18 @@ impl StorableVecGeneatorOptions { self.min, self.first, self.last, + self.total, ] .iter() .filter(|b| **b) .count() == 1 } + + pub fn copy_self_extra(&self) -> Self { + Self { + total: self.total, + ..Self::default() + } + } } diff --git a/crates/brk_computer/src/storage/vecs/grouped/from_dateindex.rs b/crates/brk_computer/src/storage/vecs/grouped/from_dateindex.rs index 0e0bada1c..d586010a8 100644 --- a/crates/brk_computer/src/storage/vecs/grouped/from_dateindex.rs +++ b/crates/brk_computer/src/storage/vecs/grouped/from_dateindex.rs @@ -2,6 +2,7 @@ use std::path::Path; use brk_core::{Dateindex, Decadeindex, Monthindex, Quarterindex, Weekindex, Yearindex}; use brk_exit::Exit; +use brk_indexer::Indexer; use brk_vec::{AnyStorableVec, Compressed, Result, Version}; use crate::storage::vecs::{Indexes, base::ComputedVec, indexes}; @@ -14,6 +15,7 @@ where T: ComputedType + PartialOrd, { pub dateindex: ComputedVec, + pub dateindex_extra: ComputedVecBuilder, pub weekindex: ComputedVecBuilder, pub monthindex: ComputedVecBuilder, pub quarterindex: ComputedVecBuilder, @@ -33,6 +35,9 @@ where compressed: Compressed, options: StorableVecGeneatorOptions, ) -> color_eyre::Result { + let dateindex_extra = + ComputedVecBuilder::forced_import(path, name, compressed, options.copy_self_extra())?; + let options = options.remove_percentiles(); Ok(Self { @@ -41,6 +46,7 @@ where version, compressed, )?, + dateindex_extra, weekindex: ComputedVecBuilder::forced_import(path, name, compressed, options)?, monthindex: ComputedVecBuilder::forced_import(path, name, compressed, options)?, quarterindex: ComputedVecBuilder::forced_import(path, name, compressed, options)?, @@ -51,15 +57,31 @@ where pub fn compute( &mut self, - mut compute: F, + indexer: &mut Indexer, indexes: &mut indexes::Vecs, starting_indexes: &Indexes, exit: &Exit, + mut compute: F, ) -> color_eyre::Result<()> where - F: FnMut(&mut ComputedVec) -> Result<()>, + F: FnMut( + &mut ComputedVec, + &mut Indexer, + &mut indexes::Vecs, + &Indexes, + &Exit, + ) -> Result<()>, { - compute(&mut self.dateindex)?; + compute( + &mut self.dateindex, + indexer, + indexes, + starting_indexes, + exit, + )?; + + self.dateindex_extra + .extend(starting_indexes.dateindex, self.dateindex.mut_vec(), exit)?; self.weekindex.compute( starting_indexes.weekindex, @@ -107,6 +129,7 @@ where pub fn any_vecs(&self) -> Vec<&dyn AnyStorableVec> { [ vec![self.dateindex.any_vec()], + self.dateindex_extra.any_vecs(), self.weekindex.any_vecs(), self.monthindex.any_vecs(), self.quarterindex.any_vecs(), diff --git a/crates/brk_computer/src/storage/vecs/grouped/from_height.rs b/crates/brk_computer/src/storage/vecs/grouped/from_height.rs index 8131e94d8..1efcc8e57 100644 --- a/crates/brk_computer/src/storage/vecs/grouped/from_height.rs +++ b/crates/brk_computer/src/storage/vecs/grouped/from_height.rs @@ -4,6 +4,7 @@ use brk_core::{ Dateindex, Decadeindex, Difficultyepoch, Height, Monthindex, Quarterindex, Weekindex, Yearindex, }; use brk_exit::Exit; +use brk_indexer::Indexer; use brk_vec::{AnyStorableVec, Compressed, Result, Version}; use crate::storage::vecs::{Indexes, base::ComputedVec, indexes}; @@ -16,6 +17,7 @@ where T: ComputedType + PartialOrd, { pub height: ComputedVec, + pub height_extra: ComputedVecBuilder, pub dateindex: ComputedVecBuilder, pub weekindex: ComputedVecBuilder, pub difficultyepoch: ComputedVecBuilder, @@ -44,12 +46,16 @@ where compressed, )?; + let height_extra = + ComputedVecBuilder::forced_import(path, name, compressed, options.copy_self_extra())?; + let dateindex = ComputedVecBuilder::forced_import(path, name, compressed, options)?; let options = options.remove_percentiles(); Ok(Self { height, + height_extra, dateindex, weekindex: ComputedVecBuilder::forced_import(path, name, compressed, options)?, difficultyepoch: ComputedVecBuilder::forced_import(path, name, compressed, options)?, @@ -63,15 +69,25 @@ where pub fn compute( &mut self, - mut compute: F, + indexer: &mut Indexer, indexes: &mut indexes::Vecs, starting_indexes: &Indexes, exit: &Exit, + mut compute: F, ) -> color_eyre::Result<()> where - F: FnMut(&mut ComputedVec) -> Result<()>, + F: FnMut( + &mut ComputedVec, + &mut Indexer, + &mut indexes::Vecs, + &Indexes, + &Exit, + ) -> Result<()>, { - compute(&mut self.height)?; + compute(&mut self.height, indexer, indexes, starting_indexes, exit)?; + + self.height_extra + .extend(starting_indexes.height, self.height.mut_vec(), exit)?; self.dateindex.compute( starting_indexes.dateindex, @@ -135,6 +151,7 @@ where pub fn any_vecs(&self) -> Vec<&dyn AnyStorableVec> { [ vec![self.height.any_vec()], + self.height_extra.any_vecs(), self.dateindex.any_vecs(), self.weekindex.any_vecs(), self.difficultyepoch.any_vecs(), diff --git a/crates/brk_computer/src/storage/vecs/grouped/from_height_strict.rs b/crates/brk_computer/src/storage/vecs/grouped/from_height_strict.rs index aa0db04ab..2a40a80e9 100644 --- a/crates/brk_computer/src/storage/vecs/grouped/from_height_strict.rs +++ b/crates/brk_computer/src/storage/vecs/grouped/from_height_strict.rs @@ -2,6 +2,7 @@ use std::path::Path; use brk_core::{Difficultyepoch, Height}; use brk_exit::Exit; +use brk_indexer::Indexer; use brk_vec::{AnyStorableVec, Compressed, Result, Version}; use crate::storage::vecs::{Indexes, base::ComputedVec, indexes}; @@ -14,6 +15,7 @@ where T: ComputedType + PartialOrd, { pub height: ComputedVec, + pub height_extra: ComputedVecBuilder, pub difficultyepoch: ComputedVecBuilder, // TODO: pub halvingepoch: StorableVecGeneator, } @@ -36,10 +38,14 @@ where compressed, )?; + let height_extra = + ComputedVecBuilder::forced_import(path, name, compressed, options.copy_self_extra())?; + let options = options.remove_percentiles(); Ok(Self { height, + height_extra, difficultyepoch: ComputedVecBuilder::forced_import(path, name, compressed, options)?, // halvingepoch: StorableVecGeneator::forced_import(path, name, compressed, options)?, }) @@ -47,15 +53,25 @@ where pub fn compute( &mut self, - mut compute: F, + indexer: &mut Indexer, indexes: &mut indexes::Vecs, starting_indexes: &Indexes, exit: &Exit, + mut compute: F, ) -> color_eyre::Result<()> where - F: FnMut(&mut ComputedVec) -> Result<()>, + F: FnMut( + &mut ComputedVec, + &mut Indexer, + &mut indexes::Vecs, + &Indexes, + &Exit, + ) -> Result<()>, { - compute(&mut self.height)?; + compute(&mut self.height, indexer, indexes, starting_indexes, exit)?; + + self.height_extra + .extend(starting_indexes.height, self.height.mut_vec(), exit)?; self.difficultyepoch.compute( starting_indexes.difficultyepoch, @@ -71,6 +87,7 @@ where pub fn any_vecs(&self) -> Vec<&dyn AnyStorableVec> { [ vec![self.height.any_vec()], + self.height_extra.any_vecs(), self.difficultyepoch.any_vecs(), // self.halvingepoch.as_any_vecs(), ] diff --git a/crates/brk_computer/src/storage/vecs/grouped/from_txindex.rs b/crates/brk_computer/src/storage/vecs/grouped/from_txindex.rs index 2dbe7a03a..d05a7dcbf 100644 --- a/crates/brk_computer/src/storage/vecs/grouped/from_txindex.rs +++ b/crates/brk_computer/src/storage/vecs/grouped/from_txindex.rs @@ -18,6 +18,7 @@ where T: ComputedType + PartialOrd, { pub txindex: ComputedVec, + pub txindex_extra: ComputedVecBuilder, pub height: ComputedVecBuilder, pub dateindex: ComputedVecBuilder, pub weekindex: ComputedVecBuilder, @@ -47,6 +48,13 @@ where compressed, )?; + let txindex_extra = ComputedVecBuilder::forced_import( + path, + name, + compressed, + StorableVecGeneatorOptions::default(), + )?; + let height = ComputedVecBuilder::forced_import(path, name, compressed, options)?; let dateindex = ComputedVecBuilder::forced_import(path, name, compressed, options)?; @@ -54,6 +62,7 @@ where Ok(Self { txindex, + txindex_extra, height, dateindex, weekindex: ComputedVecBuilder::forced_import(path, name, compressed, options)?, @@ -68,16 +77,25 @@ where pub fn compute( &mut self, - mut compute: F, indexer: &mut Indexer, indexes: &mut indexes::Vecs, starting_indexes: &Indexes, exit: &Exit, + mut compute: F, ) -> color_eyre::Result<()> where - F: FnMut(&mut ComputedVec) -> Result<()>, + F: FnMut( + &mut ComputedVec, + &mut Indexer, + &mut indexes::Vecs, + &Indexes, + &Exit, + ) -> Result<()>, { - compute(&mut self.txindex)?; + compute(&mut self.txindex, indexer, indexes, starting_indexes, exit)?; + + self.txindex_extra + .extend(starting_indexes.txindex, self.txindex.mut_vec(), exit)?; self.height.compute( starting_indexes.height, @@ -149,6 +167,7 @@ where pub fn any_vecs(&self) -> Vec<&dyn AnyStorableVec> { [ vec![self.txindex.any_vec()], + self.txindex_extra.any_vecs(), self.height.any_vecs(), self.dateindex.any_vecs(), self.weekindex.any_vecs(), diff --git a/crates/brk_computer/src/storage/vecs/marketprice.rs b/crates/brk_computer/src/storage/vecs/marketprice.rs index 2c88569dd..b77202991 100644 --- a/crates/brk_computer/src/storage/vecs/marketprice.rs +++ b/crates/brk_computer/src/storage/vecs/marketprice.rs @@ -55,9 +55,14 @@ impl Vecs { pub fn forced_import(path: &Path, compressed: Compressed) -> color_eyre::Result { fs::create_dir_all(path)?; + let mut fetched_path = path.to_owned(); + fetched_path.pop(); + fetched_path.pop(); + fetched_path = fetched_path.join("fetched/vecs"); + Ok(Self { dateindex_to_ohlc_in_cents: ComputedVec::forced_import( - &path.join("dateindex_to_ohlc_in_cents"), + &fetched_path.join("dateindex_to_ohlc_in_cents"), Version::ONE, compressed, )?, @@ -87,7 +92,7 @@ impl Vecs { compressed, )?, height_to_ohlc_in_cents: ComputedVec::forced_import( - &path.join("height_to_ohlc_in_cents"), + &fetched_path.join("height_to_ohlc_in_cents"), Version::ONE, compressed, )?, @@ -328,7 +333,11 @@ impl Vecs { )?; self.timeindexes_to_close.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.dateindex, self.dateindex_to_ohlc.mut_vec(), @@ -336,13 +345,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.timeindexes_to_high.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.dateindex, self.dateindex_to_ohlc.mut_vec(), @@ -350,13 +360,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.timeindexes_to_low.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.dateindex, self.dateindex_to_ohlc.mut_vec(), @@ -364,13 +375,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.timeindexes_to_open.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.dateindex, self.dateindex_to_ohlc.mut_vec(), @@ -378,13 +390,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.chainindexes_to_close.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.height, self.height_to_ohlc.mut_vec(), @@ -392,13 +405,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.chainindexes_to_high.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.height, self.height_to_ohlc.mut_vec(), @@ -406,13 +420,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.chainindexes_to_low.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.height, self.height_to_ohlc.mut_vec(), @@ -420,13 +435,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.chainindexes_to_open.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.height, self.height_to_ohlc.mut_vec(), @@ -434,9 +450,6 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.weekindex_to_ohlc.compute_transform( @@ -720,7 +733,11 @@ impl Vecs { )?; self.chainindexes_to_sats_per_dollar.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.height, self.chainindexes_to_close.height.mut_vec(), @@ -728,13 +745,14 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; self.timeindexes_to_sats_per_dollar.compute( - |v| { + indexer, + indexes, + starting_indexes, + exit, + |v, _, _, starting_indexes, exit| { v.compute_transform( starting_indexes.dateindex, self.timeindexes_to_close.dateindex.mut_vec(), @@ -742,9 +760,6 @@ impl Vecs { exit, ) }, - indexes, - starting_indexes, - exit, )?; Ok(()) diff --git a/crates/brk_computer/src/storage/vecs/transactions.rs b/crates/brk_computer/src/storage/vecs/transactions.rs index 10e0b8ae5..143bc8392 100644 --- a/crates/brk_computer/src/storage/vecs/transactions.rs +++ b/crates/brk_computer/src/storage/vecs/transactions.rs @@ -1,11 +1,15 @@ use std::{fs, path::Path}; -use brk_core::Txindex; +use brk_core::{CounterU64, Txindex}; use brk_exit::Exit; use brk_indexer::Indexer; use brk_vec::{AnyStorableVec, Compressed, Version}; -use super::{ComputedVec, Indexes, indexes}; +use super::{ + ComputedVec, Indexes, + grouped::{ComputedVecsFromTxindex, StorableVecGeneatorOptions}, + indexes, +}; #[derive(Clone)] pub struct Vecs { @@ -21,9 +25,9 @@ pub struct Vecs { // pub txindex_to_fee: ComputedVec, pub txindex_to_is_coinbase: ComputedVec, // pub txindex_to_feerate: ComputedVec, - pub txindex_to_inputs_count: ComputedVec, + pub txindex_to_inputs_count: ComputedVecsFromTxindex, // pub txindex_to_inputs_sum: ComputedVec, - pub txindex_to_outputs_count: ComputedVec, + pub txindex_to_outputs_count: ComputedVecsFromTxindex, // pub txindex_to_outputs_sum: ComputedVec, // pub txinindex_to_value: ComputedVec, } @@ -58,24 +62,20 @@ impl Vecs { compressed, )?, // txindex_to_feerate: StorableVec::forced_import(&path.join("txindex_to_feerate"), Version::ONE)?, - txindex_to_inputs_count: ComputedVec::forced_import( - &path.join("txindex_to_inputs_count"), + txindex_to_inputs_count: ComputedVecsFromTxindex::forced_import( + path, + "inputs_count", Version::ONE, compressed, + StorableVecGeneatorOptions::default().add_sum().add_total(), )?, - // txindex_to_inputs_sum: StorableVec::forced_import( - // &path.join("txindex_to_inputs_sum"), - // Version::ONE, - // )?, - txindex_to_outputs_count: ComputedVec::forced_import( - &path.join("txindex_to_outputs_count"), + txindex_to_outputs_count: ComputedVecsFromTxindex::forced_import( + path, + "outputs_count", Version::ONE, compressed, + StorableVecGeneatorOptions::default().add_sum().add_total(), )?, - // txindex_to_outputs_sum: StorableVec::forced_import( - // &path.join("txindex_to_outputs_sum"), - // Version::ONE, - // )?, // txinindex_to_value: StorableVec::forced_import( // &path.join("txinindex_to_value"), // Version::ONE, @@ -91,22 +91,52 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> color_eyre::Result<()> { + self.txindex_to_inputs_count.compute( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.txindex, + indexer.mut_vecs().txindex_to_first_txinindex.mut_vec(), + indexes.txindex_to_last_txinindex.mut_vec(), + exit, + ) + }, + )?; + + self.txindex_to_outputs_count.compute( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, indexes, starting_indexes, exit| { + v.compute_count_from_indexes( + starting_indexes.txindex, + indexer.mut_vecs().txindex_to_first_txoutindex.mut_vec(), + indexes.txindex_to_last_txoutindex.mut_vec(), + exit, + ) + }, + )?; + + // self.txindex_to_inputs_count.compute_count_from_indexes( + // starting_indexes.txindex, + // indexer_vecs.txindex_to_first_txinindex.mut_vec(), + // indexes.txindex_to_last_txinindex.mut_vec(), + // exit, + // )?; + + // self.txindex_to_outputs_count.compute_count_from_indexes( + // starting_indexes.txindex, + // indexer_vecs.txindex_to_first_txoutindex.mut_vec(), + // indexes.txindex_to_last_txoutindex.mut_vec(), + // exit, + // )?; + let indexer_vecs = indexer.mut_vecs(); - self.txindex_to_inputs_count.compute_count_from_indexes( - starting_indexes.txindex, - indexer_vecs.txindex_to_first_txinindex.mut_vec(), - indexes.txindex_to_last_txinindex.mut_vec(), - exit, - )?; - - self.txindex_to_outputs_count.compute_count_from_indexes( - starting_indexes.txindex, - indexer_vecs.txindex_to_first_txoutindex.mut_vec(), - indexes.txindex_to_last_txoutindex.mut_vec(), - exit, - )?; - self.txindex_to_is_coinbase.compute_is_first_ordered( starting_indexes.txindex, indexer_vecs.txindex_to_height.mut_vec(), @@ -135,31 +165,15 @@ impl Vecs { // &mut indexer.vecs().height_to_first_txindex, // )?; - // self.vecs.height_to_dateindex.compute(...) - - // --- - // Date to X - // --- - // ... - - // --- - // Month to X - // --- - // ... - - // --- - // Year to X - // --- - // ... - Ok(()) } pub fn as_any_vecs(&self) -> Vec<&dyn AnyStorableVec> { - vec![ - self.txindex_to_is_coinbase.any_vec(), - self.txindex_to_inputs_count.any_vec(), - self.txindex_to_outputs_count.any_vec(), + [ + vec![self.txindex_to_is_coinbase.any_vec()], + self.txindex_to_outputs_count.any_vecs(), + self.txindex_to_inputs_count.any_vecs(), ] + .concat() } } diff --git a/crates/brk_core/src/structs/counter_u32.rs b/crates/brk_core/src/structs/counter_u32.rs new file mode 100644 index 000000000..43c8c4495 --- /dev/null +++ b/crates/brk_core/src/structs/counter_u32.rs @@ -0,0 +1,79 @@ +use std::ops::{Add, Div}; + +use derive_deref::Deref; +use serde::Serialize; +use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; + +use crate::CheckedSub; + +#[derive( + Debug, + Deref, + Clone, + Copy, + PartialEq, + Eq, + PartialOrd, + Ord, + FromBytes, + Immutable, + IntoBytes, + KnownLayout, + Serialize, +)] +pub struct CounterU32(u32); + +impl CounterU32 { + pub const ZERO: Self = Self(0); + + pub fn new(counter: u32) -> Self { + Self(counter) + } +} + +impl From for CounterU32 { + fn from(value: u32) -> Self { + Self(value) + } +} + +impl From for CounterU32 { + fn from(value: usize) -> Self { + Self(value as u32) + } +} + +impl CheckedSub for CounterU32 { + fn checked_sub(self, rhs: Self) -> Option { + self.0.checked_sub(rhs.0).map(Self) + } +} + +impl Div for CounterU32 { + type Output = Self; + fn div(self, rhs: usize) -> Self::Output { + Self(self.0 / rhs as u32) + } +} + +impl Add for CounterU32 { + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + Self(self.0 + rhs.0) + } +} + +impl From for CounterU32 { + fn from(value: f64) -> Self { + if value < 0.0 || value > u32::MAX as f64 { + panic!() + } + Self(value as u32) + } +} + +impl From for f64 { + fn from(value: CounterU32) -> Self { + value.0 as f64 + } +} diff --git a/crates/brk_core/src/structs/counter_u64.rs b/crates/brk_core/src/structs/counter_u64.rs new file mode 100644 index 000000000..6df79bfac --- /dev/null +++ b/crates/brk_core/src/structs/counter_u64.rs @@ -0,0 +1,93 @@ +use std::ops::{Add, Div}; + +use derive_deref::Deref; +use serde::Serialize; +use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; + +use crate::CheckedSub; + +use super::{Txinindex, Txoutindex}; + +#[derive( + Debug, + Deref, + Clone, + Copy, + PartialEq, + Eq, + PartialOrd, + Ord, + FromBytes, + Immutable, + IntoBytes, + KnownLayout, + Serialize, +)] +pub struct CounterU64(u64); + +impl CounterU64 { + pub const ZERO: Self = Self(0); + + pub fn new(counter: u64) -> Self { + Self(counter) + } +} + +impl From for CounterU64 { + fn from(value: u64) -> Self { + Self(value) + } +} + +impl From for CounterU64 { + fn from(value: usize) -> Self { + Self(value as u64) + } +} + +impl CheckedSub for CounterU64 { + fn checked_sub(self, rhs: Self) -> Option { + self.0.checked_sub(rhs.0).map(Self) + } +} + +impl Div for CounterU64 { + type Output = Self; + fn div(self, rhs: usize) -> Self::Output { + Self(self.0 / rhs as u64) + } +} + +impl Add for CounterU64 { + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + Self(self.0 + rhs.0) + } +} + +impl From for CounterU64 { + fn from(value: f64) -> Self { + if value < 0.0 || value > u32::MAX as f64 { + panic!() + } + Self(value as u64) + } +} + +impl From for f64 { + fn from(value: CounterU64) -> Self { + value.0 as f64 + } +} + +impl From for CounterU64 { + fn from(value: Txinindex) -> Self { + Self(*value) + } +} + +impl From for CounterU64 { + fn from(value: Txoutindex) -> Self { + Self(*value) + } +} diff --git a/crates/brk_core/src/structs/mod.rs b/crates/brk_core/src/structs/mod.rs index 1436328c5..780c04f2e 100644 --- a/crates/brk_core/src/structs/mod.rs +++ b/crates/brk_core/src/structs/mod.rs @@ -7,6 +7,8 @@ mod bitcoin; mod blockhash; mod cents; mod compressed; +mod counter_u32; +mod counter_u64; mod date; mod dateindex; mod decadeindex; @@ -42,6 +44,8 @@ pub use bitcoin::*; pub use blockhash::*; pub use cents::*; pub use compressed::*; +pub use counter_u32::*; +pub use counter_u64::*; pub use date::*; pub use dateindex::*; pub use decadeindex::*; diff --git a/crates/brk_query/src/vec_trees.rs b/crates/brk_query/src/vec_trees.rs index 982f1f2bc..2cc22828e 100644 --- a/crates/brk_query/src/vec_trees.rs +++ b/crates/brk_query/src/vec_trees.rs @@ -17,6 +17,7 @@ impl<'a> VecTrees<'a> { let file_name = vec.file_name(); let split = file_name.split("_to_").collect::>(); if split.len() != 2 { + dbg!(&file_name, &split); panic!(); } let str = vec diff --git a/crates/brk_server/Cargo.toml b/crates/brk_server/Cargo.toml index 6db305e2d..fa6384ba7 100644 --- a/crates/brk_server/Cargo.toml +++ b/crates/brk_server/Cargo.toml @@ -23,7 +23,7 @@ log = { workspace = true } minreq = { workspace = true } oxc = { version = "0.62.0", features = ["codegen", "minifier"] } serde = { workspace = true } -tokio = { version = "1.44.1", features = ["full"] } +tokio = { version = "1.44.2", features = ["full"] } tower-http = { version = "0.6.2", features = ["compression-full", "trace"] } zip = "2.6.1" tracing = "0.1.41" diff --git a/crates/brk_server/src/lib.rs b/crates/brk_server/src/lib.rs index 10250ddf4..c0de7399e 100644 --- a/crates/brk_server/src/lib.rs +++ b/crates/brk_server/src/lib.rs @@ -129,15 +129,14 @@ impl Server { let status = response.status(); let uri = response.extensions().get::().unwrap(); match status { - StatusCode::INTERNAL_SERVER_ERROR => { - error!("{} {} {:?}", status.as_u16().red(), uri, latency) - } - StatusCode::NOT_MODIFIED => { - info!("{} {} {:?}", status.as_u16().bright_black(), uri, latency) - } StatusCode::OK => { info!("{} {} {:?}", status.as_u16().green(), uri, latency) } + StatusCode::NOT_MODIFIED + | StatusCode::TEMPORARY_REDIRECT + | StatusCode::PERMANENT_REDIRECT => { + info!("{} {} {:?}", status.as_u16().bright_black(), uri, latency) + } _ => error!("{} {} {:?}", status.as_u16().red(), uri, latency), } }, diff --git a/crates/brk_vec/src/enums/error.rs b/crates/brk_vec/src/enums/error.rs index 0050895a5..8729e5076 100644 --- a/crates/brk_vec/src/enums/error.rs +++ b/crates/brk_vec/src/enums/error.rs @@ -20,7 +20,7 @@ pub enum Error { ExpectVecToHaveIndex, FailedKeyTryIntoUsize, UnsupportedUnflushedState, - RangeFromAfterTo, + RangeFromAfterTo(usize, usize), DifferentCompressionMode, } @@ -66,7 +66,7 @@ impl fmt::Display for Error { ) } Error::ZeroCopyError => write!(f, "Zero copy convert error"), - Error::RangeFromAfterTo => write!(f, "Range, from is after to"), + Error::RangeFromAfterTo(from, to) => write!(f, "Range, from {from} is after to {to}"), Error::DifferentCompressionMode => write!(f, "Different compression mode chosen"), } } diff --git a/crates/brk_vec/src/lib.rs b/crates/brk_vec/src/lib.rs index 2a9382fc6..c0d90ee09 100644 --- a/crates/brk_vec/src/lib.rs +++ b/crates/brk_vec/src/lib.rs @@ -224,7 +224,7 @@ where }); if from > to { - return Err(Error::RangeFromAfterTo); + return Err(Error::RangeFromAfterTo(from, to)); } let mut page: Option<(usize, Values)> = None; diff --git a/websites/kibo.money/scripts/options.js b/websites/kibo.money/scripts/options.js index 9b5eb7bdc..a7ff9b951 100644 --- a/websites/kibo.money/scripts/options.js +++ b/websites/kibo.money/scripts/options.js @@ -672,10 +672,16 @@ function createPartialOptions(colors) { title: "Block Count", bottom: [ { key: "block-count", title: "Count", color: colors.bitcoin }, + { + key: "block-count-sum", + title: "Sum", + color: colors.orange, + }, { key: "total-block-count", title: "Total", - color: colors.bitcoin, + color: colors.offBitcoin, + defaultActive: false, }, ], }, @@ -754,6 +760,10 @@ function createPartialOptions(colors) { { name: "Social", tree: [ + { + name: "Github", + url: () => "https://github.com/bitcoinresearchkit/brk", + }, { name: "Nostr", url: () => @@ -767,6 +777,10 @@ function createPartialOptions(colors) { name: "Bluesky", url: () => "https://bsky.app/profile/bitcoinresearchkit.org", }, + { + name: "x", + url: () => "https://x.com/brkdotorg", + }, ], }, { @@ -777,9 +791,17 @@ function createPartialOptions(colors) { url: () => "/api", }, { - name: "Github", + name: "Source", url: () => "https://github.com/bitcoinresearchkit/brk", }, + { + name: "Status", + url: () => "https://status.kibo.money/", + }, + { + name: "Crate", + url: () => "https://crates.io/crates/brk", + }, ], }, { diff --git a/websites/kibo.money/scripts/vecid-to-indexes.js b/websites/kibo.money/scripts/vecid-to-indexes.js index df1f3a48f..7d9b65daf 100644 --- a/websites/kibo.money/scripts/vecid-to-indexes.js +++ b/websites/kibo.money/scripts/vecid-to-indexes.js @@ -52,7 +52,8 @@ export function createVecIdToIndexes() { addresstype: [Addressindex], addresstypeindex: [Addressindex], "base-size": [Txindex], - "block-count": [Dateindex], + "block-count": [Height], + "block-count-sum": [Dateindex, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "block-interval": [Height], "block-interval-10p": [Dateindex], "block-interval-25p": [Dateindex], @@ -97,6 +98,7 @@ export function createVecIdToIndexes() { high: [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "high-in-cents": [Dateindex, Height], "inputs-count": [Txindex], + "inputs-count-sum": [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "is-coinbase": [Txindex], "is-explicitly-rbf": [Txindex], "last-dateindex": [Weekindex, Monthindex], @@ -115,6 +117,7 @@ export function createVecIdToIndexes() { open: [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "open-in-cents": [Dateindex, Height], "outputs-count": [Txindex], + "outputs-count-sum": [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], p2pk33addressbytes: [P2PK33index], p2pk65addressbytes: [P2PK65index], p2pkhaddressbytes: [P2PKHindex], @@ -127,7 +130,9 @@ export function createVecIdToIndexes() { "sats-per-dollar": [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], size: [Height], timestamp: [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch, Halvingepoch], - "total-block-count": [Dateindex], + "total-block-count": [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], + "total-inputs-count": [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], + "total-outputs-count": [Dateindex, Height, Weekindex, Monthindex, Quarterindex, Yearindex, Decadeindex, Difficultyepoch], "total-size": [Txindex], txid: [Txindex], txoutindex: [Txinindex],