mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-01 18:09:59 -07:00
computer: remove the need for &mut vecs
This commit is contained in:
@@ -7,7 +7,7 @@ use brk_core::{
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_parser::bitcoin;
|
||||
use brk_vec::{Compressed, StoredIndex, Version};
|
||||
use brk_vec::{Compressed, Version};
|
||||
use color_eyre::eyre::ContextCompat;
|
||||
|
||||
use super::{
|
||||
@@ -110,8 +110,8 @@ impl Vecs {
|
||||
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<()> {
|
||||
@@ -123,7 +123,7 @@ impl Vecs {
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
indexes.dateindex_to_date.mut_vec(),
|
||||
indexes.dateindex_to_date.vec(),
|
||||
|(di, d, ..)| (di, Timestamp::from(d)),
|
||||
exit,
|
||||
)
|
||||
@@ -136,18 +136,18 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, _, starting_indexes, exit| {
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
let indexer_vecs = indexer.vecs();
|
||||
|
||||
v.compute_range(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_weight.mut_vec(),
|
||||
indexer_vecs.height_to_weight.vec(),
|
||||
|h| (h, StoredU32::from(1_u32)),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
let indexer_vecs = indexer.vecs();
|
||||
|
||||
self.height_to_interval.compute_transform(
|
||||
starting_indexes.height,
|
||||
@@ -155,7 +155,7 @@ impl Vecs {
|
||||
|(height, timestamp, _, height_to_timestamp_iter)| {
|
||||
let interval = height.decremented().map_or(Timestamp::ZERO, |prev_h| {
|
||||
let prev_timestamp = height_to_timestamp_iter
|
||||
.get(prev_h.unwrap_to_usize())
|
||||
.get(prev_h)
|
||||
.context("To work")
|
||||
.inspect_err(|_| {
|
||||
dbg!(prev_h);
|
||||
@@ -176,26 +176,26 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(self.height_to_interval.mut_vec()),
|
||||
Some(self.height_to_interval.vec()),
|
||||
)?;
|
||||
|
||||
self.indexes_to_block_weight.compute_rest(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(indexer_vecs.height_to_weight.mut_vec()),
|
||||
Some(indexer_vecs.height_to_weight.vec()),
|
||||
)?;
|
||||
|
||||
self.indexes_to_block_size.compute_rest(
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(indexer_vecs.height_to_total_size.mut_vec()),
|
||||
Some(indexer_vecs.height_to_total_size.vec()),
|
||||
)?;
|
||||
|
||||
self.height_to_vbytes.compute_transform(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_weight.mut_vec(),
|
||||
indexer_vecs.height_to_weight.vec(),
|
||||
|(h, w, ..)| {
|
||||
(
|
||||
h,
|
||||
@@ -209,30 +209,22 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(self.height_to_vbytes.mut_vec()),
|
||||
Some(self.height_to_vbytes.vec()),
|
||||
)?;
|
||||
|
||||
let mut height_to_timestamp_iter = indexer_vecs.height_to_timestamp.iter();
|
||||
|
||||
self.difficultyepoch_to_timestamp.compute_transform(
|
||||
starting_indexes.difficultyepoch,
|
||||
indexes.difficultyepoch_to_first_height.mut_vec(),
|
||||
|(i, h, ..)| {
|
||||
(
|
||||
i,
|
||||
indexer_vecs.height_to_timestamp.double_unwrap_cached_get(h),
|
||||
)
|
||||
},
|
||||
indexes.difficultyepoch_to_first_height.vec(),
|
||||
|(i, h, ..)| (i, height_to_timestamp_iter.get(h).unwrap().1.into_inner()),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.halvingepoch_to_timestamp.compute_transform(
|
||||
starting_indexes.halvingepoch,
|
||||
indexes.halvingepoch_to_first_height.mut_vec(),
|
||||
|(i, h, ..)| {
|
||||
(
|
||||
i,
|
||||
indexer_vecs.height_to_timestamp.double_unwrap_cached_get(h),
|
||||
)
|
||||
},
|
||||
indexes.halvingepoch_to_first_height.vec(),
|
||||
|(i, h, ..)| (i, height_to_timestamp_iter.get(h).unwrap().1.into_inner()),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_core::CheckedSub;
|
||||
use brk_exit::Exit;
|
||||
use brk_vec::{
|
||||
Compressed, DynamicVec, GenericVec, Result, StoredIndex, StoredType, StoredVec, Version,
|
||||
};
|
||||
use brk_vec::{Compressed, DynamicVec, Result, StoredIndex, StoredType, StoredVec, Version};
|
||||
use color_eyre::eyre::ContextCompat;
|
||||
|
||||
use crate::storage::{ComputedType, EagerVec};
|
||||
@@ -136,7 +135,7 @@ where
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
pub fn extend(&mut self, max_from: I, source: &mut StoredVec<I, T>, exit: &Exit) -> Result<()> {
|
||||
pub fn extend(&mut self, max_from: I, source: &StoredVec<I, T>, exit: &Exit) -> Result<()> {
|
||||
if self.total.is_none() {
|
||||
return Ok(());
|
||||
};
|
||||
@@ -170,31 +169,34 @@ where
|
||||
pub fn compute<I2>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
source: &mut StoredVec<I2, T>,
|
||||
first_indexes: &mut StoredVec<I, I2>,
|
||||
last_indexes: &mut StoredVec<I, I2>,
|
||||
source: &StoredVec<I2, T>,
|
||||
first_indexes: &StoredVec<I, I2>,
|
||||
last_indexes: &StoredVec<I, I2>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
I2: StoredIndex + StoredType,
|
||||
I2: StoredIndex + StoredType + CheckedSub<I2>,
|
||||
{
|
||||
let index = self.starting_index(max_from);
|
||||
|
||||
let mut last_indexes_iter = last_indexes.iter();
|
||||
let mut source_iter = source.iter();
|
||||
|
||||
first_indexes
|
||||
.into_iter()
|
||||
.skip(index.unwrap_to_usize())
|
||||
.try_for_each(|(i, first_index)| -> Result<()> {
|
||||
let first_index = first_index.into_inner();
|
||||
|
||||
let last_index = last_indexes.double_unwrap_cached_get(i);
|
||||
let last_index = last_indexes_iter.get(i).unwrap().1.into_inner();
|
||||
|
||||
if let Some(first) = self.first.as_mut() {
|
||||
let v = source.double_unwrap_cached_get(first_index);
|
||||
let v = source_iter.get(first_index).unwrap().1.into_inner();
|
||||
first.forced_push_at(index, v, exit)?;
|
||||
}
|
||||
|
||||
if let Some(last) = self.last.as_mut() {
|
||||
let v = source.double_unwrap_cached_get(last_index);
|
||||
let v = source_iter.get(last_index).unwrap().1.into_inner();
|
||||
last.forced_push_at(index, v, exit)?;
|
||||
}
|
||||
|
||||
@@ -210,7 +212,16 @@ where
|
||||
let needs_values = needs_sorted || needs_average_sum_or_total;
|
||||
|
||||
if needs_values {
|
||||
let mut values = source.collect_inclusive_range(first_index, last_index)?;
|
||||
source_iter.set(first_index);
|
||||
let mut values = (&mut source_iter)
|
||||
.take(
|
||||
last_index
|
||||
.checked_sub(first_index)
|
||||
.unwrap()
|
||||
.unwrap_to_usize(),
|
||||
)
|
||||
.map(|(_, v)| v.into_inner())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if needs_sorted {
|
||||
values.sort_unstable();
|
||||
@@ -303,13 +314,13 @@ where
|
||||
pub fn from_aligned<I2>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
source: &mut ComputedVecBuilder<I2, T>,
|
||||
first_indexes: &mut StoredVec<I, I2>,
|
||||
last_indexes: &mut StoredVec<I, I2>,
|
||||
source: &ComputedVecBuilder<I2, T>,
|
||||
first_indexes: &StoredVec<I, I2>,
|
||||
last_indexes: &StoredVec<I, I2>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
I2: StoredIndex + StoredType,
|
||||
I2: StoredIndex + StoredType + CheckedSub<I2>,
|
||||
{
|
||||
if self._90p.is_some()
|
||||
|| self._75p.is_some()
|
||||
@@ -322,29 +333,36 @@ where
|
||||
|
||||
let index = self.starting_index(max_from);
|
||||
|
||||
let mut last_indexes_iter = last_indexes.iter();
|
||||
|
||||
let mut source_first_iter = source.first.as_ref().map(|f| f.iter());
|
||||
let mut source_last_iter = source.last.as_ref().map(|f| f.iter());
|
||||
let mut source_max_iter = source.max.as_ref().map(|f| f.iter());
|
||||
let mut source_min_iter = source.min.as_ref().map(|f| f.iter());
|
||||
let mut source_average_iter = source.average.as_ref().map(|f| f.iter());
|
||||
let mut source_sum_iter = source.sum.as_ref().map(|f| f.iter());
|
||||
|
||||
first_indexes
|
||||
.into_iter()
|
||||
.skip(index.unwrap_to_usize())
|
||||
.try_for_each(|(i, first_index, ..)| -> Result<()> {
|
||||
let first_index = first_index.into_inner();
|
||||
|
||||
let last_index = last_indexes.double_unwrap_cached_get(i);
|
||||
let last_index = last_indexes_iter.get(i).unwrap().1.into_inner();
|
||||
|
||||
if let Some(first) = self.first.as_mut() {
|
||||
let v = source
|
||||
.first
|
||||
let v = source_first_iter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.double_unwrap_cached_get(first_index);
|
||||
.unwrap_get_inner(first_index);
|
||||
first.forced_push_at(index, v, exit)?;
|
||||
}
|
||||
|
||||
if let Some(last) = self.last.as_mut() {
|
||||
let v = source
|
||||
.last
|
||||
let v = source_last_iter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.double_unwrap_cached_get(last_index);
|
||||
.unwrap_get_inner(last_index);
|
||||
last.forced_push_at(index, v, exit)?;
|
||||
}
|
||||
|
||||
@@ -356,21 +374,35 @@ where
|
||||
if needs_values {
|
||||
if needs_sorted {
|
||||
if let Some(max) = self.max.as_mut() {
|
||||
let mut values = source
|
||||
.max
|
||||
.as_ref()
|
||||
let mut values = source_max_iter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.collect_inclusive_range(first_index, last_index)?;
|
||||
.skip(first_index.unwrap_to_usize())
|
||||
.take(
|
||||
last_index
|
||||
.checked_sub(first_index)
|
||||
.unwrap()
|
||||
.unwrap_to_usize(),
|
||||
)
|
||||
.map(|(_, v)| v.into_inner())
|
||||
.collect::<Vec<_>>();
|
||||
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()
|
||||
let mut values = source_min_iter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.collect_inclusive_range(first_index, last_index)?;
|
||||
.skip(first_index.unwrap_to_usize())
|
||||
.take(
|
||||
last_index
|
||||
.checked_sub(first_index)
|
||||
.unwrap()
|
||||
.unwrap_to_usize(),
|
||||
)
|
||||
.map(|(_, v)| v.into_inner())
|
||||
.collect::<Vec<_>>();
|
||||
values.sort_unstable();
|
||||
min.forced_push_at(i, values.first().unwrap().clone(), exit)?;
|
||||
}
|
||||
@@ -378,11 +410,18 @@ where
|
||||
|
||||
if needs_average_sum_or_total {
|
||||
if let Some(average) = self.average.as_mut() {
|
||||
let values = source
|
||||
.average
|
||||
.as_ref()
|
||||
let values = source_average_iter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.collect_inclusive_range(first_index, last_index)?;
|
||||
.skip(first_index.unwrap_to_usize())
|
||||
.take(
|
||||
last_index
|
||||
.checked_sub(first_index)
|
||||
.unwrap()
|
||||
.unwrap_to_usize(),
|
||||
)
|
||||
.map(|(_, v)| v.into_inner())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let len = values.len();
|
||||
let total = values.into_iter().fold(T::from(0), |a, b| a + b);
|
||||
@@ -393,11 +432,18 @@ where
|
||||
}
|
||||
|
||||
if needs_sum_or_total {
|
||||
let values = source
|
||||
.sum
|
||||
.as_ref()
|
||||
let values = source_sum_iter
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.collect_inclusive_range(first_index, last_index)?;
|
||||
.skip(first_index.unwrap_to_usize())
|
||||
.take(
|
||||
last_index
|
||||
.checked_sub(first_index)
|
||||
.unwrap()
|
||||
.unwrap_to_usize(),
|
||||
)
|
||||
.map(|(_, v)| v.into_inner())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let sum = values.into_iter().fold(T::from(0), |a, b| a + b);
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ where
|
||||
|
||||
pub fn compute<F>(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
@@ -80,8 +80,8 @@ where
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<DateIndex, T>,
|
||||
&mut Indexer,
|
||||
&mut indexes::Vecs,
|
||||
&Indexer,
|
||||
&indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
@@ -95,45 +95,45 @@ where
|
||||
)?;
|
||||
|
||||
self.dateindex_extra
|
||||
.extend(starting_indexes.dateindex, self.dateindex.mut_vec(), exit)?;
|
||||
.extend(starting_indexes.dateindex, self.dateindex.vec(), exit)?;
|
||||
|
||||
self.weekindex.compute(
|
||||
starting_indexes.weekindex,
|
||||
self.dateindex.mut_vec(),
|
||||
indexes.weekindex_to_first_dateindex.mut_vec(),
|
||||
indexes.weekindex_to_last_dateindex.mut_vec(),
|
||||
self.dateindex.vec(),
|
||||
indexes.weekindex_to_first_dateindex.vec(),
|
||||
indexes.weekindex_to_last_dateindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.monthindex.compute(
|
||||
starting_indexes.monthindex,
|
||||
self.dateindex.mut_vec(),
|
||||
indexes.monthindex_to_first_dateindex.mut_vec(),
|
||||
indexes.monthindex_to_last_dateindex.mut_vec(),
|
||||
self.dateindex.vec(),
|
||||
indexes.monthindex_to_first_dateindex.vec(),
|
||||
indexes.monthindex_to_last_dateindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.quarterindex.from_aligned(
|
||||
starting_indexes.quarterindex,
|
||||
&mut self.monthindex,
|
||||
indexes.quarterindex_to_first_monthindex.mut_vec(),
|
||||
indexes.quarterindex_to_last_monthindex.mut_vec(),
|
||||
&self.monthindex,
|
||||
indexes.quarterindex_to_first_monthindex.vec(),
|
||||
indexes.quarterindex_to_last_monthindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.yearindex.from_aligned(
|
||||
starting_indexes.yearindex,
|
||||
&mut self.monthindex,
|
||||
indexes.yearindex_to_first_monthindex.mut_vec(),
|
||||
indexes.yearindex_to_last_monthindex.mut_vec(),
|
||||
&self.monthindex,
|
||||
indexes.yearindex_to_first_monthindex.vec(),
|
||||
indexes.yearindex_to_last_monthindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.decadeindex.from_aligned(
|
||||
starting_indexes.decadeindex,
|
||||
&mut self.yearindex,
|
||||
indexes.decadeindex_to_first_yearindex.mut_vec(),
|
||||
indexes.decadeindex_to_last_yearindex.mut_vec(),
|
||||
&self.yearindex,
|
||||
indexes.decadeindex_to_first_yearindex.vec(),
|
||||
indexes.decadeindex_to_last_yearindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -87,20 +87,14 @@ where
|
||||
|
||||
pub fn compute_all<F>(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
) -> color_eyre::Result<()>
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<Height, T>,
|
||||
&mut Indexer,
|
||||
&mut indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<Height, T>, &Indexer, &indexes::Vecs, &Indexes, &Exit) -> Result<()>,
|
||||
{
|
||||
compute(
|
||||
self.height.as_mut().unwrap(),
|
||||
@@ -117,12 +111,12 @@ where
|
||||
|
||||
pub fn compute_rest(
|
||||
&mut self,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
height: Option<&mut StoredVec<Height, T>>,
|
||||
height: Option<&StoredVec<Height, T>>,
|
||||
) -> color_eyre::Result<()> {
|
||||
let height = height.unwrap_or_else(|| self.height.as_mut().unwrap().mut_vec());
|
||||
let height = height.unwrap_or_else(|| self.height.as_ref().unwrap().vec());
|
||||
|
||||
self.height_extra
|
||||
.extend(starting_indexes.height, height, exit)?;
|
||||
@@ -130,56 +124,56 @@ where
|
||||
self.dateindex.compute(
|
||||
starting_indexes.dateindex,
|
||||
height,
|
||||
indexes.dateindex_to_first_height.mut_vec(),
|
||||
indexes.dateindex_to_last_height.mut_vec(),
|
||||
indexes.dateindex_to_first_height.vec(),
|
||||
indexes.dateindex_to_last_height.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.weekindex.from_aligned(
|
||||
starting_indexes.weekindex,
|
||||
&mut self.dateindex,
|
||||
indexes.weekindex_to_first_dateindex.mut_vec(),
|
||||
indexes.weekindex_to_last_dateindex.mut_vec(),
|
||||
&self.dateindex,
|
||||
indexes.weekindex_to_first_dateindex.vec(),
|
||||
indexes.weekindex_to_last_dateindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.monthindex.from_aligned(
|
||||
starting_indexes.monthindex,
|
||||
&mut self.dateindex,
|
||||
indexes.monthindex_to_first_dateindex.mut_vec(),
|
||||
indexes.monthindex_to_last_dateindex.mut_vec(),
|
||||
&self.dateindex,
|
||||
indexes.monthindex_to_first_dateindex.vec(),
|
||||
indexes.monthindex_to_last_dateindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.quarterindex.from_aligned(
|
||||
starting_indexes.quarterindex,
|
||||
&mut self.monthindex,
|
||||
indexes.quarterindex_to_first_monthindex.mut_vec(),
|
||||
indexes.quarterindex_to_last_monthindex.mut_vec(),
|
||||
&self.monthindex,
|
||||
indexes.quarterindex_to_first_monthindex.vec(),
|
||||
indexes.quarterindex_to_last_monthindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.yearindex.from_aligned(
|
||||
starting_indexes.yearindex,
|
||||
&mut self.monthindex,
|
||||
indexes.yearindex_to_first_monthindex.mut_vec(),
|
||||
indexes.yearindex_to_last_monthindex.mut_vec(),
|
||||
&self.monthindex,
|
||||
indexes.yearindex_to_first_monthindex.vec(),
|
||||
indexes.yearindex_to_last_monthindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.decadeindex.from_aligned(
|
||||
starting_indexes.decadeindex,
|
||||
&mut self.yearindex,
|
||||
indexes.decadeindex_to_first_yearindex.mut_vec(),
|
||||
indexes.decadeindex_to_last_yearindex.mut_vec(),
|
||||
&self.yearindex,
|
||||
indexes.decadeindex_to_first_yearindex.vec(),
|
||||
indexes.decadeindex_to_last_yearindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.difficultyepoch.compute(
|
||||
starting_indexes.difficultyepoch,
|
||||
height,
|
||||
indexes.difficultyepoch_to_first_height.mut_vec(),
|
||||
indexes.difficultyepoch_to_last_height.mut_vec(),
|
||||
indexes.difficultyepoch_to_first_height.vec(),
|
||||
indexes.difficultyepoch_to_last_height.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -61,31 +61,25 @@ where
|
||||
|
||||
pub fn compute<F>(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
) -> color_eyre::Result<()>
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<Height, T>,
|
||||
&mut Indexer,
|
||||
&mut indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
F: FnMut(&mut EagerVec<Height, T>, &Indexer, &indexes::Vecs, &Indexes, &Exit) -> Result<()>,
|
||||
{
|
||||
compute(&mut self.height, indexer, indexes, starting_indexes, exit)?;
|
||||
|
||||
self.height_extra
|
||||
.extend(starting_indexes.height, self.height.mut_vec(), exit)?;
|
||||
.extend(starting_indexes.height, self.height.vec(), exit)?;
|
||||
|
||||
self.difficultyepoch.compute(
|
||||
starting_indexes.difficultyepoch,
|
||||
self.height.mut_vec(),
|
||||
indexes.difficultyepoch_to_first_height.mut_vec(),
|
||||
indexes.difficultyepoch_to_last_height.mut_vec(),
|
||||
self.height.vec(),
|
||||
indexes.difficultyepoch_to_first_height.vec(),
|
||||
indexes.difficultyepoch_to_last_height.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ where
|
||||
|
||||
pub fn compute_all<F>(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
@@ -92,8 +92,8 @@ where
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<TxIndex, T>,
|
||||
&mut Indexer,
|
||||
&mut indexes::Vecs,
|
||||
&Indexer,
|
||||
&indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
@@ -113,75 +113,75 @@ where
|
||||
|
||||
pub fn compute_rest(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
txindex: Option<&mut StoredVec<TxIndex, T>>,
|
||||
txindex: Option<&StoredVec<TxIndex, T>>,
|
||||
) -> color_eyre::Result<()> {
|
||||
let txindex = txindex.unwrap_or_else(|| self.txindex.as_mut().unwrap().mut_vec());
|
||||
let txindex = txindex.unwrap_or_else(|| self.txindex.as_ref().unwrap().vec());
|
||||
|
||||
self.height.compute(
|
||||
starting_indexes.height,
|
||||
txindex,
|
||||
indexer.mut_vecs().height_to_first_txindex.mut_vec(),
|
||||
indexes.height_to_last_txindex.mut_vec(),
|
||||
indexer.vecs().height_to_first_txindex.vec(),
|
||||
indexes.height_to_last_txindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex.from_aligned(
|
||||
starting_indexes.dateindex,
|
||||
&mut self.height,
|
||||
indexes.dateindex_to_first_height.mut_vec(),
|
||||
indexes.dateindex_to_last_height.mut_vec(),
|
||||
&self.height,
|
||||
indexes.dateindex_to_first_height.vec(),
|
||||
indexes.dateindex_to_last_height.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.weekindex.from_aligned(
|
||||
starting_indexes.weekindex,
|
||||
&mut self.dateindex,
|
||||
indexes.weekindex_to_first_dateindex.mut_vec(),
|
||||
indexes.weekindex_to_last_dateindex.mut_vec(),
|
||||
&self.dateindex,
|
||||
indexes.weekindex_to_first_dateindex.vec(),
|
||||
indexes.weekindex_to_last_dateindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.monthindex.from_aligned(
|
||||
starting_indexes.monthindex,
|
||||
&mut self.dateindex,
|
||||
indexes.monthindex_to_first_dateindex.mut_vec(),
|
||||
indexes.monthindex_to_last_dateindex.mut_vec(),
|
||||
&self.dateindex,
|
||||
indexes.monthindex_to_first_dateindex.vec(),
|
||||
indexes.monthindex_to_last_dateindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.quarterindex.from_aligned(
|
||||
starting_indexes.quarterindex,
|
||||
&mut self.monthindex,
|
||||
indexes.quarterindex_to_first_monthindex.mut_vec(),
|
||||
indexes.quarterindex_to_last_monthindex.mut_vec(),
|
||||
&self.monthindex,
|
||||
indexes.quarterindex_to_first_monthindex.vec(),
|
||||
indexes.quarterindex_to_last_monthindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.yearindex.from_aligned(
|
||||
starting_indexes.yearindex,
|
||||
&mut self.monthindex,
|
||||
indexes.yearindex_to_first_monthindex.mut_vec(),
|
||||
indexes.yearindex_to_last_monthindex.mut_vec(),
|
||||
&self.monthindex,
|
||||
indexes.yearindex_to_first_monthindex.vec(),
|
||||
indexes.yearindex_to_last_monthindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.decadeindex.from_aligned(
|
||||
starting_indexes.decadeindex,
|
||||
&mut self.yearindex,
|
||||
indexes.decadeindex_to_first_yearindex.mut_vec(),
|
||||
indexes.decadeindex_to_last_yearindex.mut_vec(),
|
||||
&self.yearindex,
|
||||
indexes.decadeindex_to_first_yearindex.vec(),
|
||||
indexes.decadeindex_to_last_yearindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.difficultyepoch.from_aligned(
|
||||
starting_indexes.difficultyepoch,
|
||||
&mut self.height,
|
||||
indexes.difficultyepoch_to_first_height.mut_vec(),
|
||||
indexes.difficultyepoch_to_last_height.mut_vec(),
|
||||
&self.height,
|
||||
indexes.difficultyepoch_to_first_height.vec(),
|
||||
indexes.difficultyepoch_to_last_height.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -64,9 +64,9 @@ impl ComputedValueVecsFromHeight {
|
||||
|
||||
pub fn compute_all<F>(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
marketprices: &mut Option<&mut marketprice::Vecs>,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
marketprices: Option<&marketprice::Vecs>,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
@@ -74,8 +74,8 @@ impl ComputedValueVecsFromHeight {
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<Height, Sats>,
|
||||
&mut Indexer,
|
||||
&mut indexes::Vecs,
|
||||
&Indexer,
|
||||
&indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
@@ -95,14 +95,14 @@ impl ComputedValueVecsFromHeight {
|
||||
|
||||
pub fn compute_rest(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
marketprices: &mut Option<&mut marketprice::Vecs>,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
marketprices: Option<&marketprice::Vecs>,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut height: Option<&mut StoredVec<Height, Sats>>,
|
||||
height: Option<&StoredVec<Height, Sats>>,
|
||||
) -> color_eyre::Result<()> {
|
||||
if let Some(height) = height.as_mut() {
|
||||
if let Some(height) = height.as_ref() {
|
||||
self.sats
|
||||
.compute_rest(indexes, starting_indexes, exit, Some(height))?;
|
||||
} else {
|
||||
@@ -110,7 +110,7 @@ impl ComputedValueVecsFromHeight {
|
||||
.compute_rest(indexes, starting_indexes, exit, None)?;
|
||||
}
|
||||
|
||||
let height = height.unwrap_or_else(|| self.sats.height.as_mut().unwrap().mut_vec());
|
||||
let height = height.unwrap_or_else(|| self.sats.height.as_ref().unwrap().vec());
|
||||
|
||||
self.bitcoin.compute_all(
|
||||
indexer,
|
||||
@@ -122,13 +122,13 @@ impl ComputedValueVecsFromHeight {
|
||||
},
|
||||
)?;
|
||||
|
||||
let txindex = self.bitcoin.height.as_mut().unwrap().mut_vec();
|
||||
let txindex = self.bitcoin.height.as_ref().unwrap().vec();
|
||||
let price = marketprices
|
||||
.as_mut()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.chainindexes_to_close
|
||||
.height
|
||||
.mut_vec();
|
||||
.vec();
|
||||
|
||||
if let Some(dollars) = self.dollars.as_mut() {
|
||||
dollars.compute_all(
|
||||
|
||||
@@ -64,9 +64,9 @@ impl ComputedValueVecsFromTxindex {
|
||||
|
||||
pub fn compute_all<F>(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
marketprices: &mut Option<&mut marketprice::Vecs>,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
marketprices: Option<&marketprice::Vecs>,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut compute: F,
|
||||
@@ -74,8 +74,8 @@ impl ComputedValueVecsFromTxindex {
|
||||
where
|
||||
F: FnMut(
|
||||
&mut EagerVec<TxIndex, Sats>,
|
||||
&mut Indexer,
|
||||
&mut indexes::Vecs,
|
||||
&Indexer,
|
||||
&indexes::Vecs,
|
||||
&Indexes,
|
||||
&Exit,
|
||||
) -> Result<()>,
|
||||
@@ -95,14 +95,14 @@ impl ComputedValueVecsFromTxindex {
|
||||
|
||||
pub fn compute_rest(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
marketprices: &mut Option<&mut marketprice::Vecs>,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
marketprices: Option<&marketprice::Vecs>,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
mut txindex: Option<&mut StoredVec<TxIndex, Sats>>,
|
||||
txindex: Option<&StoredVec<TxIndex, Sats>>,
|
||||
) -> color_eyre::Result<()> {
|
||||
if let Some(txindex) = txindex.as_mut() {
|
||||
if let Some(txindex) = txindex.as_ref() {
|
||||
self.sats
|
||||
.compute_rest(indexer, indexes, starting_indexes, exit, Some(txindex))?;
|
||||
} else {
|
||||
@@ -110,7 +110,7 @@ impl ComputedValueVecsFromTxindex {
|
||||
.compute_rest(indexer, indexes, starting_indexes, exit, None)?;
|
||||
}
|
||||
|
||||
let txindex = txindex.unwrap_or_else(|| self.sats.txindex.as_mut().unwrap().mut_vec());
|
||||
let txindex = txindex.unwrap_or_else(|| self.sats.txindex.as_ref().unwrap().vec());
|
||||
|
||||
self.bitcoin.compute_all(
|
||||
indexer,
|
||||
@@ -123,14 +123,10 @@ impl ComputedValueVecsFromTxindex {
|
||||
)?;
|
||||
|
||||
let txindex = self.bitcoin.txindex.as_mut().unwrap().mut_vec();
|
||||
let price = marketprices
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.chainindexes_to_close
|
||||
.height
|
||||
.mut_vec();
|
||||
|
||||
if let Some(dollars) = self.dollars.as_mut() {
|
||||
let price = marketprices.unwrap().chainindexes_to_close.height.vec();
|
||||
|
||||
dollars.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
@@ -140,7 +136,7 @@ impl ComputedValueVecsFromTxindex {
|
||||
v.compute_from_bitcoin(
|
||||
starting_indexes.txindex,
|
||||
txindex,
|
||||
indexes.txindex_to_height.mut_vec(),
|
||||
indexes.txindex_to_height.vec(),
|
||||
price,
|
||||
exit,
|
||||
)
|
||||
|
||||
@@ -36,19 +36,19 @@ pub struct Vecs {
|
||||
pub height_to_difficultyepoch: EagerVec<Height, DifficultyEpoch>,
|
||||
pub height_to_halvingepoch: EagerVec<Height, HalvingEpoch>,
|
||||
pub height_to_height: EagerVec<Height, Height>,
|
||||
pub height_to_last_emptyoutputindex: EagerVec<Height, EmptyOutputIndex>,
|
||||
pub height_to_last_opreturnindex: EagerVec<Height, OpReturnIndex>,
|
||||
pub height_to_last_p2aindex: EagerVec<Height, P2AIndex>,
|
||||
pub height_to_last_p2msindex: EagerVec<Height, P2MSIndex>,
|
||||
pub height_to_last_p2pk33index: EagerVec<Height, P2PK33Index>,
|
||||
pub height_to_last_p2pk65index: EagerVec<Height, P2PK65Index>,
|
||||
pub height_to_last_p2pkhindex: EagerVec<Height, P2PKHIndex>,
|
||||
pub height_to_last_p2shindex: EagerVec<Height, P2SHIndex>,
|
||||
pub height_to_last_p2trindex: EagerVec<Height, P2TRIndex>,
|
||||
pub height_to_last_p2wpkhindex: EagerVec<Height, P2WPKHIndex>,
|
||||
pub height_to_last_p2wshindex: EagerVec<Height, P2WSHIndex>,
|
||||
// pub height_to_last_emptyoutputindex: EagerVec<Height, EmptyOutputIndex>,
|
||||
// pub height_to_last_opreturnindex: EagerVec<Height, OpReturnIndex>,
|
||||
// pub height_to_last_p2aindex: EagerVec<Height, P2AIndex>,
|
||||
// pub height_to_last_p2msindex: EagerVec<Height, P2MSIndex>,
|
||||
// pub height_to_last_p2pk33index: EagerVec<Height, P2PK33Index>,
|
||||
// pub height_to_last_p2pk65index: EagerVec<Height, P2PK65Index>,
|
||||
// pub height_to_last_p2pkhindex: EagerVec<Height, P2PKHIndex>,
|
||||
// pub height_to_last_p2shindex: EagerVec<Height, P2SHIndex>,
|
||||
// pub height_to_last_p2trindex: EagerVec<Height, P2TRIndex>,
|
||||
// pub height_to_last_p2wpkhindex: EagerVec<Height, P2WPKHIndex>,
|
||||
// pub height_to_last_p2wshindex: EagerVec<Height, P2WSHIndex>,
|
||||
pub height_to_last_txindex: EagerVec<Height, TxIndex>,
|
||||
pub height_to_last_unknownoutputindex: EagerVec<Height, UnknownOutputIndex>,
|
||||
// pub height_to_last_unknownoutputindex: EagerVec<Height, UnknownOutputIndex>,
|
||||
pub height_to_timestamp_fixed: EagerVec<Height, Timestamp>,
|
||||
pub inputindex_to_inputindex: EagerVec<InputIndex, InputIndex>,
|
||||
pub monthindex_to_first_dateindex: EagerVec<MonthIndex, DateIndex>,
|
||||
@@ -369,76 +369,76 @@ 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,
|
||||
)?,
|
||||
// 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,
|
||||
// )?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexer: &Indexer,
|
||||
starting_indexes: brk_indexer::Indexes,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<Indexes> {
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
let indexer_vecs = indexer.vecs();
|
||||
|
||||
let height_count = indexer_vecs.height_to_total_size.len();
|
||||
let txindexes_count = indexer_vecs.txindex_to_txid.len();
|
||||
@@ -451,84 +451,84 @@ impl Vecs {
|
||||
|
||||
self.outputindex_to_outputindex.compute_range(
|
||||
starting_indexes.outputindex,
|
||||
indexer_vecs.outputindex_to_value.mut_vec(),
|
||||
indexer_vecs.outputindex_to_value.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2pk33index_to_p2pk33index.compute_range(
|
||||
starting_indexes.p2pk33index,
|
||||
indexer_vecs.p2pk33index_to_p2pk33bytes.mut_vec(),
|
||||
indexer_vecs.p2pk33index_to_p2pk33bytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2pk65index_to_p2pk65index.compute_range(
|
||||
starting_indexes.p2pk65index,
|
||||
indexer_vecs.p2pk65index_to_p2pk65bytes.mut_vec(),
|
||||
indexer_vecs.p2pk65index_to_p2pk65bytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2pkhindex_to_p2pkhindex.compute_range(
|
||||
starting_indexes.p2pkhindex,
|
||||
indexer_vecs.p2pkhindex_to_p2pkhbytes.mut_vec(),
|
||||
indexer_vecs.p2pkhindex_to_p2pkhbytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2shindex_to_p2shindex.compute_range(
|
||||
starting_indexes.p2shindex,
|
||||
indexer_vecs.p2shindex_to_p2shbytes.mut_vec(),
|
||||
indexer_vecs.p2shindex_to_p2shbytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2trindex_to_p2trindex.compute_range(
|
||||
starting_indexes.p2trindex,
|
||||
indexer_vecs.p2trindex_to_p2trbytes.mut_vec(),
|
||||
indexer_vecs.p2trindex_to_p2trbytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2wpkhindex_to_p2wpkhindex.compute_range(
|
||||
starting_indexes.p2wpkhindex,
|
||||
indexer_vecs.p2wpkhindex_to_p2wpkhbytes.mut_vec(),
|
||||
indexer_vecs.p2wpkhindex_to_p2wpkhbytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2wshindex_to_p2wshindex.compute_range(
|
||||
starting_indexes.p2wshindex,
|
||||
indexer_vecs.p2wshindex_to_p2wshbytes.mut_vec(),
|
||||
indexer_vecs.p2wshindex_to_p2wshbytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.emptyoutputindex_to_emptyoutputindex.compute_range(
|
||||
starting_indexes.emptyoutputindex,
|
||||
indexer_vecs.emptyoutputindex_to_txindex.mut_vec(),
|
||||
indexer_vecs.emptyoutputindex_to_txindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2msindex_to_p2msindex.compute_range(
|
||||
starting_indexes.p2msindex,
|
||||
indexer_vecs.p2msindex_to_txindex.mut_vec(),
|
||||
indexer_vecs.p2msindex_to_txindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.opreturnindex_to_opreturnindex.compute_range(
|
||||
starting_indexes.opreturnindex,
|
||||
indexer_vecs.opreturnindex_to_txindex.mut_vec(),
|
||||
indexer_vecs.opreturnindex_to_txindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.p2aindex_to_p2aindex.compute_range(
|
||||
starting_indexes.p2aindex,
|
||||
indexer_vecs.p2aindex_to_p2abytes.mut_vec(),
|
||||
indexer_vecs.p2aindex_to_p2abytes.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
@@ -536,105 +536,105 @@ impl Vecs {
|
||||
self.unknownoutputindex_to_unknownoutputindex
|
||||
.compute_range(
|
||||
starting_indexes.unknownoutputindex,
|
||||
indexer_vecs.unknownoutputindex_to_txindex.mut_vec(),
|
||||
indexer_vecs.unknownoutputindex_to_txindex.vec(),
|
||||
|i| (i, i),
|
||||
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_p2aindex.compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2aindex.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_p2msindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2msindex.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_p2pk33index
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2pk33index.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_p2pk65index
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2pk65index.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_p2pkhindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2pkhindex.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_p2shindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2shindex.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_p2trindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2trindex.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_p2wpkhindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2wpkhindex.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_p2wshindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_p2wshindex.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_opreturnindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_opreturnindex.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_unknownoutputindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_unknownoutputindex.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,
|
||||
)?;
|
||||
// self.height_to_last_emptyoutputindex
|
||||
// .compute_last_index_from_first(
|
||||
// starting_indexes.height,
|
||||
// indexer_vecs.height_to_first_emptyoutputindex.vec(),
|
||||
// height_count,
|
||||
// exit,
|
||||
// )?;
|
||||
|
||||
// ---
|
||||
// InputIndex
|
||||
@@ -642,7 +642,7 @@ impl Vecs {
|
||||
|
||||
self.inputindex_to_inputindex.compute_range(
|
||||
starting_indexes.inputindex,
|
||||
indexer_vecs.inputindex_to_outputindex.mut_vec(),
|
||||
indexer_vecs.inputindex_to_outputindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
@@ -654,7 +654,7 @@ impl Vecs {
|
||||
self.txindex_to_last_inputindex
|
||||
.compute_last_index_from_first(
|
||||
starting_indexes.txindex,
|
||||
indexer_vecs.txindex_to_first_inputindex.mut_vec(),
|
||||
indexer_vecs.txindex_to_first_inputindex.vec(),
|
||||
inputindexes_count,
|
||||
exit,
|
||||
)?;
|
||||
@@ -662,29 +662,29 @@ impl Vecs {
|
||||
self.txindex_to_last_outputindex
|
||||
.compute_last_index_from_first(
|
||||
starting_indexes.txindex,
|
||||
indexer_vecs.txindex_to_first_outputindex.mut_vec(),
|
||||
indexer_vecs.txindex_to_first_outputindex.vec(),
|
||||
outputindexes_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.txindex_to_txindex.compute_range(
|
||||
starting_indexes.txindex,
|
||||
self.txindex_to_last_inputindex.mut_vec(),
|
||||
self.txindex_to_last_inputindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_last_txindex.compute_last_index_from_first(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_first_txindex.mut_vec(),
|
||||
indexer_vecs.height_to_first_txindex.vec(),
|
||||
txindexes_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.txindex_to_height.compute_inverse_less_to_more(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_first_txindex.mut_vec(),
|
||||
self.height_to_last_txindex.mut_vec(),
|
||||
indexer_vecs.height_to_first_txindex.vec(),
|
||||
self.height_to_last_txindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -694,21 +694,21 @@ impl Vecs {
|
||||
|
||||
self.height_to_height.compute_range(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_timestamp.mut_vec(),
|
||||
indexer_vecs.height_to_timestamp.vec(),
|
||||
|h| (h, h),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_date.compute_transform(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_timestamp.mut_vec(),
|
||||
indexer_vecs.height_to_timestamp.vec(),
|
||||
|(h, t, ..)| (h, Date::from(t)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_timestamp_fixed.compute_transform(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_timestamp.mut_vec(),
|
||||
indexer_vecs.height_to_timestamp.vec(),
|
||||
|(h, timestamp, s, ..)| {
|
||||
let timestamp = h
|
||||
.decremented()
|
||||
@@ -721,7 +721,7 @@ impl Vecs {
|
||||
|
||||
self.height_to_date_fixed.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_timestamp_fixed.mut_vec(),
|
||||
self.height_to_timestamp_fixed.vec(),
|
||||
|(h, t, ..)| (h, Date::from(t)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -739,7 +739,7 @@ impl Vecs {
|
||||
|
||||
self.height_to_dateindex.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_date_fixed.mut_vec(),
|
||||
self.height_to_date_fixed.vec(),
|
||||
|(h, d, ..)| (h, DateIndex::try_from(d).unwrap()),
|
||||
exit,
|
||||
)?;
|
||||
@@ -756,7 +756,7 @@ impl Vecs {
|
||||
self.dateindex_to_first_height
|
||||
.compute_inverse_more_to_less(
|
||||
starting_indexes.height,
|
||||
self.height_to_dateindex.mut_vec(),
|
||||
self.height_to_dateindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -765,21 +765,21 @@ impl Vecs {
|
||||
self.dateindex_to_last_height
|
||||
.compute_last_index_from_first(
|
||||
starting_dateindex,
|
||||
self.dateindex_to_first_height.mut_vec(),
|
||||
self.dateindex_to_first_height.vec(),
|
||||
height_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_dateindex.compute_range(
|
||||
starting_dateindex,
|
||||
self.dateindex_to_first_height.mut_vec(),
|
||||
self.dateindex_to_first_height.vec(),
|
||||
|di| (di, di),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_date.compute_range(
|
||||
starting_dateindex,
|
||||
self.dateindex_to_dateindex.mut_vec(),
|
||||
self.dateindex_to_dateindex.vec(),
|
||||
|di| (di, Date::from(di)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -795,7 +795,7 @@ impl Vecs {
|
||||
|
||||
self.dateindex_to_weekindex.compute_range(
|
||||
starting_dateindex,
|
||||
self.dateindex_to_dateindex.mut_vec(),
|
||||
self.dateindex_to_dateindex.vec(),
|
||||
|di| (di, WeekIndex::from(di)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -803,21 +803,21 @@ impl Vecs {
|
||||
self.weekindex_to_first_dateindex
|
||||
.compute_inverse_more_to_less(
|
||||
starting_dateindex,
|
||||
self.dateindex_to_weekindex.mut_vec(),
|
||||
self.dateindex_to_weekindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.weekindex_to_last_dateindex
|
||||
.compute_last_index_from_first(
|
||||
starting_weekindex,
|
||||
self.weekindex_to_first_dateindex.mut_vec(),
|
||||
self.weekindex_to_first_dateindex.vec(),
|
||||
date_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.weekindex_to_weekindex.compute_range(
|
||||
starting_weekindex,
|
||||
self.weekindex_to_first_dateindex.mut_vec(),
|
||||
self.weekindex_to_first_dateindex.vec(),
|
||||
|wi| (wi, wi),
|
||||
exit,
|
||||
)?;
|
||||
@@ -833,7 +833,7 @@ impl Vecs {
|
||||
|
||||
self.height_to_difficultyepoch.compute_range(
|
||||
starting_indexes.height,
|
||||
self.height_to_height.mut_vec(),
|
||||
self.height_to_height.vec(),
|
||||
|h| (h, DifficultyEpoch::from(h)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -841,21 +841,21 @@ impl Vecs {
|
||||
self.difficultyepoch_to_first_height
|
||||
.compute_inverse_more_to_less(
|
||||
starting_indexes.height,
|
||||
self.height_to_difficultyepoch.mut_vec(),
|
||||
self.height_to_difficultyepoch.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.difficultyepoch_to_last_height
|
||||
.compute_last_index_from_first(
|
||||
starting_difficultyepoch,
|
||||
self.difficultyepoch_to_first_height.mut_vec(),
|
||||
self.difficultyepoch_to_first_height.vec(),
|
||||
height_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.difficultyepoch_to_difficultyepoch.compute_range(
|
||||
starting_difficultyepoch,
|
||||
self.difficultyepoch_to_first_height.mut_vec(),
|
||||
self.difficultyepoch_to_first_height.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
@@ -871,7 +871,7 @@ impl Vecs {
|
||||
|
||||
self.dateindex_to_monthindex.compute_range(
|
||||
starting_dateindex,
|
||||
self.dateindex_to_dateindex.mut_vec(),
|
||||
self.dateindex_to_dateindex.vec(),
|
||||
|di| (di, MonthIndex::from(di)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -879,7 +879,7 @@ impl Vecs {
|
||||
self.monthindex_to_first_dateindex
|
||||
.compute_inverse_more_to_less(
|
||||
starting_dateindex,
|
||||
self.dateindex_to_monthindex.mut_vec(),
|
||||
self.dateindex_to_monthindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -888,14 +888,14 @@ impl Vecs {
|
||||
self.monthindex_to_last_dateindex
|
||||
.compute_last_index_from_first(
|
||||
starting_monthindex,
|
||||
self.monthindex_to_first_dateindex.mut_vec(),
|
||||
self.monthindex_to_first_dateindex.vec(),
|
||||
date_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.monthindex_to_monthindex.compute_range(
|
||||
starting_monthindex,
|
||||
self.monthindex_to_first_dateindex.mut_vec(),
|
||||
self.monthindex_to_first_dateindex.vec(),
|
||||
|mi| (mi, mi),
|
||||
exit,
|
||||
)?;
|
||||
@@ -911,7 +911,7 @@ impl Vecs {
|
||||
|
||||
self.monthindex_to_quarterindex.compute_range(
|
||||
starting_monthindex,
|
||||
self.monthindex_to_monthindex.mut_vec(),
|
||||
self.monthindex_to_monthindex.vec(),
|
||||
|mi| (mi, QuarterIndex::from(mi)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -919,7 +919,7 @@ impl Vecs {
|
||||
self.quarterindex_to_first_monthindex
|
||||
.compute_inverse_more_to_less(
|
||||
starting_monthindex,
|
||||
self.monthindex_to_quarterindex.mut_vec(),
|
||||
self.monthindex_to_quarterindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -928,14 +928,14 @@ impl Vecs {
|
||||
self.quarterindex_to_last_monthindex
|
||||
.compute_last_index_from_first(
|
||||
starting_quarterindex,
|
||||
self.quarterindex_to_first_monthindex.mut_vec(),
|
||||
self.quarterindex_to_first_monthindex.vec(),
|
||||
month_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.quarterindex_to_quarterindex.compute_range(
|
||||
starting_quarterindex,
|
||||
self.quarterindex_to_first_monthindex.mut_vec(),
|
||||
self.quarterindex_to_first_monthindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
@@ -951,7 +951,7 @@ impl Vecs {
|
||||
|
||||
self.monthindex_to_yearindex.compute_range(
|
||||
starting_monthindex,
|
||||
self.monthindex_to_monthindex.mut_vec(),
|
||||
self.monthindex_to_monthindex.vec(),
|
||||
|i| (i, YearIndex::from(i)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -959,7 +959,7 @@ impl Vecs {
|
||||
self.yearindex_to_first_monthindex
|
||||
.compute_inverse_more_to_less(
|
||||
starting_monthindex,
|
||||
self.monthindex_to_yearindex.mut_vec(),
|
||||
self.monthindex_to_yearindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -968,14 +968,14 @@ impl Vecs {
|
||||
self.yearindex_to_last_monthindex
|
||||
.compute_last_index_from_first(
|
||||
starting_yearindex,
|
||||
self.yearindex_to_first_monthindex.mut_vec(),
|
||||
self.yearindex_to_first_monthindex.vec(),
|
||||
month_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.yearindex_to_yearindex.compute_range(
|
||||
starting_yearindex,
|
||||
self.yearindex_to_first_monthindex.mut_vec(),
|
||||
self.yearindex_to_first_monthindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
@@ -991,7 +991,7 @@ impl Vecs {
|
||||
|
||||
self.height_to_halvingepoch.compute_range(
|
||||
starting_indexes.height,
|
||||
self.height_to_height.mut_vec(),
|
||||
self.height_to_height.vec(),
|
||||
|h| (h, HalvingEpoch::from(h)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -999,21 +999,21 @@ impl Vecs {
|
||||
self.halvingepoch_to_first_height
|
||||
.compute_inverse_more_to_less(
|
||||
starting_indexes.height,
|
||||
self.height_to_halvingepoch.mut_vec(),
|
||||
self.height_to_halvingepoch.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.halvingepoch_to_last_height
|
||||
.compute_last_index_from_first(
|
||||
starting_halvingepoch,
|
||||
self.halvingepoch_to_first_height.mut_vec(),
|
||||
self.halvingepoch_to_first_height.vec(),
|
||||
height_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.halvingepoch_to_halvingepoch.compute_range(
|
||||
starting_halvingepoch,
|
||||
self.halvingepoch_to_first_height.mut_vec(),
|
||||
self.halvingepoch_to_first_height.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
@@ -1029,7 +1029,7 @@ impl Vecs {
|
||||
|
||||
self.yearindex_to_decadeindex.compute_range(
|
||||
starting_yearindex,
|
||||
self.yearindex_to_yearindex.mut_vec(),
|
||||
self.yearindex_to_yearindex.vec(),
|
||||
|i| (i, DecadeIndex::from(i)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -1037,21 +1037,21 @@ impl Vecs {
|
||||
self.decadeindex_to_first_yearindex
|
||||
.compute_inverse_more_to_less(
|
||||
starting_yearindex,
|
||||
self.yearindex_to_decadeindex.mut_vec(),
|
||||
self.yearindex_to_decadeindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.decadeindex_to_last_yearindex
|
||||
.compute_last_index_from_first(
|
||||
starting_decadeindex,
|
||||
self.decadeindex_to_first_yearindex.mut_vec(),
|
||||
self.decadeindex_to_first_yearindex.vec(),
|
||||
year_count,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.decadeindex_to_decadeindex.compute_range(
|
||||
starting_decadeindex,
|
||||
self.decadeindex_to_first_yearindex.mut_vec(),
|
||||
self.decadeindex_to_first_yearindex.vec(),
|
||||
|i| (i, i),
|
||||
exit,
|
||||
)?;
|
||||
@@ -1126,18 +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(),
|
||||
// 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(),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use brk_core::{
|
||||
use brk_exit::Exit;
|
||||
use brk_fetcher::Fetcher;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{Compressed, StoredIndex, Version};
|
||||
use brk_vec::{Compressed, Version};
|
||||
|
||||
use super::{
|
||||
EagerVec, Indexes,
|
||||
@@ -325,28 +325,24 @@ impl Vecs {
|
||||
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
fetcher: &mut Fetcher,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<()> {
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
let indexer_vecs = indexer.vecs();
|
||||
|
||||
self.height_to_ohlc_in_cents.compute_transform(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_timestamp.mut_vec(),
|
||||
indexer_vecs.height_to_timestamp.vec(),
|
||||
|(h, t, _, height_to_timestamp_iter)| {
|
||||
let ohlc = fetcher
|
||||
.get_height(
|
||||
h,
|
||||
t,
|
||||
h.decremented().map(|prev_h| {
|
||||
height_to_timestamp_iter
|
||||
.get(prev_h.unwrap_to_usize())
|
||||
.unwrap()
|
||||
.1
|
||||
.into_inner()
|
||||
height_to_timestamp_iter.get(prev_h).unwrap().1.into_inner()
|
||||
}),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -357,42 +353,42 @@ impl Vecs {
|
||||
|
||||
self.height_to_open_in_cents.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc_in_cents.mut_vec(),
|
||||
self.height_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.open),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_high_in_cents.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc_in_cents.mut_vec(),
|
||||
self.height_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.high),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_low_in_cents.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc_in_cents.mut_vec(),
|
||||
self.height_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.low),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_close_in_cents.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc_in_cents.mut_vec(),
|
||||
self.height_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.close),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.height_to_ohlc.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc_in_cents.mut_vec(),
|
||||
self.height_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, OHLCDollars::from(ohlc)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_ohlc_in_cents.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
indexes.dateindex_to_date.mut_vec(),
|
||||
indexes.dateindex_to_date.vec(),
|
||||
|(di, d, ..)| {
|
||||
let ohlc = fetcher.get_date(d).unwrap();
|
||||
(di, ohlc)
|
||||
@@ -402,35 +398,35 @@ impl Vecs {
|
||||
|
||||
self.dateindex_to_open_in_cents.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc_in_cents.mut_vec(),
|
||||
self.dateindex_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.open),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_high_in_cents.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc_in_cents.mut_vec(),
|
||||
self.dateindex_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.high),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_low_in_cents.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc_in_cents.mut_vec(),
|
||||
self.dateindex_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.low),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_close_in_cents.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc_in_cents.mut_vec(),
|
||||
self.dateindex_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.close),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex_to_ohlc.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc_in_cents.mut_vec(),
|
||||
self.dateindex_to_ohlc_in_cents.vec(),
|
||||
|(di, ohlc, ..)| (di, OHLCDollars::from(ohlc)),
|
||||
exit,
|
||||
)?;
|
||||
@@ -443,7 +439,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc.mut_vec(),
|
||||
self.dateindex_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.close),
|
||||
exit,
|
||||
)
|
||||
@@ -458,7 +454,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc.mut_vec(),
|
||||
self.dateindex_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.high),
|
||||
exit,
|
||||
)
|
||||
@@ -473,7 +469,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc.mut_vec(),
|
||||
self.dateindex_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.low),
|
||||
exit,
|
||||
)
|
||||
@@ -488,7 +484,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.dateindex_to_ohlc.mut_vec(),
|
||||
self.dateindex_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.open),
|
||||
exit,
|
||||
)
|
||||
@@ -503,7 +499,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc.mut_vec(),
|
||||
self.height_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.close),
|
||||
exit,
|
||||
)
|
||||
@@ -518,7 +514,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc.mut_vec(),
|
||||
self.height_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.high),
|
||||
exit,
|
||||
)
|
||||
@@ -533,7 +529,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc.mut_vec(),
|
||||
self.height_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.low),
|
||||
exit,
|
||||
)
|
||||
@@ -548,7 +544,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.height_to_ohlc.mut_vec(),
|
||||
self.height_to_ohlc.vec(),
|
||||
|(di, ohlc, ..)| (di, ohlc.open),
|
||||
exit,
|
||||
)
|
||||
@@ -557,7 +553,7 @@ impl Vecs {
|
||||
|
||||
self.weekindex_to_ohlc.compute_transform(
|
||||
starting_indexes.weekindex,
|
||||
self.timeindexes_to_close.weekindex.unwrap_last().mut_vec(),
|
||||
self.timeindexes_to_close.weekindex.unwrap_last().vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -589,7 +585,7 @@ impl Vecs {
|
||||
self.chainindexes_to_close
|
||||
.difficultyepoch
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -618,7 +614,7 @@ impl Vecs {
|
||||
|
||||
self.monthindex_to_ohlc.compute_transform(
|
||||
starting_indexes.monthindex,
|
||||
self.timeindexes_to_close.monthindex.unwrap_last().mut_vec(),
|
||||
self.timeindexes_to_close.monthindex.unwrap_last().vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -647,10 +643,7 @@ impl Vecs {
|
||||
|
||||
self.quarterindex_to_ohlc.compute_transform(
|
||||
starting_indexes.quarterindex,
|
||||
self.timeindexes_to_close
|
||||
.quarterindex
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
self.timeindexes_to_close.quarterindex.unwrap_last().vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -679,7 +672,7 @@ impl Vecs {
|
||||
|
||||
self.yearindex_to_ohlc.compute_transform(
|
||||
starting_indexes.yearindex,
|
||||
self.timeindexes_to_close.yearindex.unwrap_last().mut_vec(),
|
||||
self.timeindexes_to_close.yearindex.unwrap_last().vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -711,10 +704,7 @@ impl Vecs {
|
||||
|
||||
self.decadeindex_to_ohlc.compute_transform(
|
||||
starting_indexes.decadeindex,
|
||||
self.timeindexes_to_close
|
||||
.decadeindex
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
self.timeindexes_to_close.decadeindex.unwrap_last().vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -749,7 +739,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.chainindexes_to_open.height.mut_vec(),
|
||||
self.chainindexes_to_open.height.vec(),
|
||||
|(i, open, ..)| (i, Open::new(Sats::ONE_BTC / *open)),
|
||||
exit,
|
||||
)
|
||||
@@ -764,7 +754,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.chainindexes_to_low.height.mut_vec(),
|
||||
self.chainindexes_to_low.height.vec(),
|
||||
|(i, low, ..)| (i, High::new(Sats::ONE_BTC / *low)),
|
||||
exit,
|
||||
)
|
||||
@@ -779,7 +769,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.chainindexes_to_high.height.mut_vec(),
|
||||
self.chainindexes_to_high.height.vec(),
|
||||
|(i, high, ..)| (i, Low::new(Sats::ONE_BTC / *high)),
|
||||
exit,
|
||||
)
|
||||
@@ -794,7 +784,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.chainindexes_to_close.height.mut_vec(),
|
||||
self.chainindexes_to_close.height.vec(),
|
||||
|(i, close, ..)| (i, Close::new(Sats::ONE_BTC / *close)),
|
||||
exit,
|
||||
)
|
||||
@@ -809,7 +799,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.timeindexes_to_open.dateindex.mut_vec(),
|
||||
self.timeindexes_to_open.dateindex.vec(),
|
||||
|(i, open, ..)| (i, Open::new(Sats::ONE_BTC / *open)),
|
||||
exit,
|
||||
)
|
||||
@@ -824,7 +814,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.timeindexes_to_low.dateindex.mut_vec(),
|
||||
self.timeindexes_to_low.dateindex.vec(),
|
||||
|(i, low, ..)| (i, High::new(Sats::ONE_BTC / *low)),
|
||||
exit,
|
||||
)
|
||||
@@ -839,7 +829,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.timeindexes_to_high.dateindex.mut_vec(),
|
||||
self.timeindexes_to_high.dateindex.vec(),
|
||||
|(i, high, ..)| (i, Low::new(Sats::ONE_BTC / *high)),
|
||||
exit,
|
||||
)
|
||||
@@ -854,7 +844,7 @@ impl Vecs {
|
||||
|v, _, _, starting_indexes, exit| {
|
||||
v.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.timeindexes_to_close.dateindex.mut_vec(),
|
||||
self.timeindexes_to_close.dateindex.vec(),
|
||||
|(i, close, ..)| (i, Close::new(Sats::ONE_BTC / *close)),
|
||||
exit,
|
||||
)
|
||||
@@ -863,7 +853,7 @@ impl Vecs {
|
||||
|
||||
self.height_to_ohlc_in_sats.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.chainindexes_to_close_in_sats.height.mut_vec(),
|
||||
self.chainindexes_to_close_in_sats.height.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -889,7 +879,7 @@ impl Vecs {
|
||||
|
||||
self.dateindex_to_ohlc_in_sats.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
self.timeindexes_to_close_in_sats.dateindex.mut_vec(),
|
||||
self.timeindexes_to_close_in_sats.dateindex.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -918,7 +908,7 @@ impl Vecs {
|
||||
self.timeindexes_to_close_in_sats
|
||||
.weekindex
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -950,7 +940,7 @@ impl Vecs {
|
||||
self.chainindexes_to_close_in_sats
|
||||
.difficultyepoch
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -982,7 +972,7 @@ impl Vecs {
|
||||
self.timeindexes_to_close_in_sats
|
||||
.monthindex
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -1014,7 +1004,7 @@ impl Vecs {
|
||||
self.timeindexes_to_close_in_sats
|
||||
.quarterindex
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -1046,7 +1036,7 @@ impl Vecs {
|
||||
self.timeindexes_to_close_in_sats
|
||||
.yearindex
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -1081,7 +1071,7 @@ impl Vecs {
|
||||
self.timeindexes_to_close_in_sats
|
||||
.decadeindex
|
||||
.unwrap_last()
|
||||
.mut_vec(),
|
||||
.vec(),
|
||||
|(i, close, ..)| {
|
||||
(
|
||||
i,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{fs, path::Path};
|
||||
use brk_core::{DifficultyEpoch, HalvingEpoch, StoredF64};
|
||||
use brk_exit::Exit;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_vec::{Compressed, DynamicVec, Version};
|
||||
use brk_vec::{Compressed, Version};
|
||||
|
||||
use super::{
|
||||
Indexes,
|
||||
@@ -50,11 +50,12 @@ impl Vecs {
|
||||
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<()> {
|
||||
let mut height_to_difficultyepoch_iter = indexes.height_to_difficultyepoch.iter();
|
||||
self.indexes_to_difficultyepoch.compute(
|
||||
indexer,
|
||||
indexes,
|
||||
@@ -63,14 +64,15 @@ impl Vecs {
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
indexes.dateindex_to_last_height.mut_vec(),
|
||||
indexes.dateindex_to_last_height.vec(),
|
||||
|(di, height, ..)| {
|
||||
(
|
||||
di,
|
||||
indexes
|
||||
.height_to_difficultyepoch
|
||||
.mut_vec()
|
||||
.double_unwrap_cached_get(height),
|
||||
height_to_difficultyepoch_iter
|
||||
.get(height)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_inner(),
|
||||
)
|
||||
},
|
||||
exit,
|
||||
@@ -78,6 +80,7 @@ impl Vecs {
|
||||
},
|
||||
)?;
|
||||
|
||||
let mut height_to_halvingepoch_iter = indexes.height_to_halvingepoch.iter();
|
||||
self.indexes_to_halvingepoch.compute(
|
||||
indexer,
|
||||
indexes,
|
||||
@@ -86,16 +89,8 @@ impl Vecs {
|
||||
|vec, _, indexes, starting_indexes, exit| {
|
||||
vec.compute_transform(
|
||||
starting_indexes.dateindex,
|
||||
indexes.dateindex_to_last_height.mut_vec(),
|
||||
|(di, height, ..)| {
|
||||
(
|
||||
di,
|
||||
indexes
|
||||
.height_to_halvingepoch
|
||||
.mut_vec()
|
||||
.double_unwrap_cached_get(height),
|
||||
)
|
||||
},
|
||||
indexes.dateindex_to_last_height.vec(),
|
||||
|(di, height, ..)| (di, height_to_halvingepoch_iter.unwrap_get_inner(height)),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -105,7 +100,7 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(indexer.mut_vecs().height_to_difficulty.mut_vec()),
|
||||
Some(indexer.vecs().height_to_difficulty.vec()),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Vecs {
|
||||
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexer: &Indexer,
|
||||
starting_indexes: brk_indexer::Indexes,
|
||||
fetcher: Option<&mut Fetcher>,
|
||||
exit: &Exit,
|
||||
@@ -48,15 +48,15 @@ impl Vecs {
|
||||
let starting_indexes = self.indexes.compute(indexer, starting_indexes, exit)?;
|
||||
|
||||
self.blocks
|
||||
.compute(indexer, &mut self.indexes, &starting_indexes, exit)?;
|
||||
.compute(indexer, &self.indexes, &starting_indexes, exit)?;
|
||||
|
||||
self.mining
|
||||
.compute(indexer, &mut self.indexes, &starting_indexes, exit)?;
|
||||
.compute(indexer, &self.indexes, &starting_indexes, exit)?;
|
||||
|
||||
if let Some(marketprice) = self.marketprice.as_mut() {
|
||||
marketprice.compute(
|
||||
indexer,
|
||||
&mut self.indexes,
|
||||
&self.indexes,
|
||||
&starting_indexes,
|
||||
fetcher.unwrap(),
|
||||
exit,
|
||||
@@ -65,9 +65,9 @@ impl Vecs {
|
||||
|
||||
self.transactions.compute(
|
||||
indexer,
|
||||
&mut self.indexes,
|
||||
&self.indexes,
|
||||
&starting_indexes,
|
||||
&mut self.marketprice.as_mut(),
|
||||
self.marketprice.as_ref(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -407,10 +407,10 @@ impl Vecs {
|
||||
|
||||
pub fn compute(
|
||||
&mut self,
|
||||
indexer: &mut Indexer,
|
||||
indexes: &mut indexes::Vecs,
|
||||
indexer: &Indexer,
|
||||
indexes: &indexes::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
marketprices: &mut Option<&mut marketprice::Vecs>,
|
||||
marketprices: Option<&marketprice::Vecs>,
|
||||
exit: &Exit,
|
||||
) -> color_eyre::Result<()> {
|
||||
self.indexes_to_tx_count.compute_all(
|
||||
@@ -418,11 +418,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, starting_indexes, exit| {
|
||||
v.compute_count_from_indexes(
|
||||
starting_indexes.height,
|
||||
indexer.mut_vecs().height_to_first_txindex.mut_vec(),
|
||||
indexes.height_to_last_txindex.mut_vec(),
|
||||
indexer.vecs().height_to_first_txindex.vec(),
|
||||
indexer.vecs().txindex_to_txid.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -433,11 +433,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, starting_indexes, exit| {
|
||||
v.compute_count_from_indexes(
|
||||
starting_indexes.txindex,
|
||||
indexer.mut_vecs().txindex_to_first_inputindex.mut_vec(),
|
||||
indexes.txindex_to_last_inputindex.mut_vec(),
|
||||
indexer.vecs().txindex_to_first_inputindex.vec(),
|
||||
indexer.vecs().inputindex_to_outputindex.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -448,33 +448,35 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, starting_indexes, exit| {
|
||||
v.compute_count_from_indexes(
|
||||
starting_indexes.txindex,
|
||||
indexer.mut_vecs().txindex_to_first_outputindex.mut_vec(),
|
||||
indexes.txindex_to_last_outputindex.mut_vec(),
|
||||
indexer.vecs().txindex_to_first_outputindex.vec(),
|
||||
indexer.vecs().outputindex_to_value.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
let mut compute_indexes_to_tx_vany =
|
||||
let compute_indexes_to_tx_vany =
|
||||
|indexes_to_tx_vany: &mut ComputedVecsFromHeight<StoredU32>, txversion| {
|
||||
let mut txindex_to_txversion_iter = indexer.vecs().txindex_to_txversion.iter();
|
||||
indexes_to_tx_vany.compute_all(
|
||||
indexer,
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, indexer, indexes, starting_indexes, exit| {
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
|vec, indexer, _, starting_indexes, exit| {
|
||||
vec.compute_filtered_count_from_indexes(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_first_txindex.mut_vec(),
|
||||
indexes.height_to_last_txindex.mut_vec(),
|
||||
indexer.vecs().height_to_first_txindex.vec(),
|
||||
indexer.vecs().txindex_to_txid.vec(),
|
||||
|txindex| {
|
||||
let v = indexer_vecs
|
||||
.txindex_to_txversion
|
||||
.double_unwrap_cached_get(txindex);
|
||||
let v = txindex_to_txversion_iter
|
||||
.get(txindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_inner();
|
||||
v == txversion
|
||||
},
|
||||
exit,
|
||||
@@ -486,23 +488,23 @@ impl Vecs {
|
||||
compute_indexes_to_tx_vany(&mut self.indexes_to_tx_v2, TxVersion::TWO)?;
|
||||
compute_indexes_to_tx_vany(&mut self.indexes_to_tx_v3, TxVersion::THREE)?;
|
||||
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
|
||||
self.txindex_to_is_coinbase.compute_is_first_ordered(
|
||||
starting_indexes.txindex,
|
||||
indexes.txindex_to_height.mut_vec(),
|
||||
indexer_vecs.height_to_first_txindex.mut_vec(),
|
||||
indexes.txindex_to_height.vec(),
|
||||
indexer.vecs().height_to_first_txindex.vec(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
let mut txindex_to_total_size_iter = indexer.vecs().txindex_to_total_size.iter();
|
||||
self.txindex_to_weight.compute_transform(
|
||||
starting_indexes.txindex,
|
||||
indexer_vecs.txindex_to_base_size.mut_vec(),
|
||||
indexer.vecs().txindex_to_base_size.vec(),
|
||||
|(txindex, base_size, ..)| {
|
||||
let total_size = indexer_vecs
|
||||
.txindex_to_total_size
|
||||
.mut_vec()
|
||||
.double_unwrap_cached_get(txindex);
|
||||
let total_size = txindex_to_total_size_iter
|
||||
.get(txindex)
|
||||
.unwrap()
|
||||
.1
|
||||
.into_inner();
|
||||
|
||||
// This is the exact definition of a weight unit, as defined by BIP-141 (quote above).
|
||||
let wu = usize::from(base_size) * 3 + usize::from(total_size);
|
||||
@@ -515,7 +517,7 @@ impl Vecs {
|
||||
|
||||
self.txindex_to_vsize.compute_transform(
|
||||
starting_indexes.txindex,
|
||||
self.txindex_to_weight.mut_vec(),
|
||||
self.txindex_to_weight.vec(),
|
||||
|(txindex, weight, ..)| {
|
||||
let vbytes =
|
||||
StoredUsize::from(bitcoin::Weight::from(weight).to_vbytes_ceil() as usize);
|
||||
@@ -524,19 +526,16 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
let inputs_len = indexer_vecs.inputindex_to_outputindex.vec().len();
|
||||
let mut outputindex_to_value_iter = indexer.vecs().outputindex_to_value.iter();
|
||||
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(),
|
||||
indexer.vecs().inputindex_to_outputindex.vec(),
|
||||
|(inputindex, outputindex, slf, ..)| {
|
||||
let value = if outputindex == OutputIndex::COINBASE {
|
||||
Sats::ZERO
|
||||
} else if let Some(value) = indexer_vecs
|
||||
.outputindex_to_value
|
||||
.mut_vec()
|
||||
.unwrap_cached_get(outputindex)
|
||||
{
|
||||
value
|
||||
} else if let Some((_, value)) = outputindex_to_value_iter.get(outputindex) {
|
||||
value.into_inner()
|
||||
} else {
|
||||
dbg!(inputindex, outputindex, slf.len(), inputs_len);
|
||||
panic!()
|
||||
@@ -552,12 +551,11 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, indexer, indexes, starting_indexes, exit| {
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
vec.compute_sum_from_indexes(
|
||||
starting_indexes.txindex,
|
||||
indexer_vecs.txindex_to_first_outputindex.mut_vec(),
|
||||
indexes.txindex_to_last_outputindex.mut_vec(),
|
||||
indexer_vecs.outputindex_to_value.mut_vec(),
|
||||
indexer.vecs().txindex_to_first_outputindex.vec(),
|
||||
indexes.txindex_to_last_outputindex.vec(),
|
||||
indexer.vecs().outputindex_to_value.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -569,12 +567,11 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, indexer, indexes, starting_indexes, exit| {
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
vec.compute_sum_from_indexes(
|
||||
starting_indexes.txindex,
|
||||
indexer_vecs.txindex_to_first_inputindex.mut_vec(),
|
||||
indexes.txindex_to_last_inputindex.mut_vec(),
|
||||
self.inputindex_to_value.mut_vec(),
|
||||
indexer.vecs().txindex_to_first_inputindex.vec(),
|
||||
indexes.txindex_to_last_inputindex.vec(),
|
||||
self.inputindex_to_value.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -587,25 +584,21 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, _, starting_indexes, exit| {
|
||||
let txindex_to_output_value = self
|
||||
let mut txindex_to_output_value_iter = self
|
||||
.indexes_to_output_value
|
||||
.txindex
|
||||
.as_mut()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.mut_vec();
|
||||
.iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.txindex,
|
||||
self.indexes_to_input_value
|
||||
.txindex
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.mut_vec(),
|
||||
self.indexes_to_input_value.txindex.as_ref().unwrap().vec(),
|
||||
|(txindex, input_value, ..)| {
|
||||
if input_value.is_zero() {
|
||||
(txindex, input_value)
|
||||
} else {
|
||||
let output_value =
|
||||
txindex_to_output_value.double_unwrap_cached_get(txindex);
|
||||
txindex_to_output_value_iter.unwrap_get_inner(txindex);
|
||||
(txindex, input_value.checked_sub(output_value).unwrap())
|
||||
}
|
||||
},
|
||||
@@ -620,15 +613,12 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, _, starting_indexes, exit| {
|
||||
let mut txindex_to_vsize_iter = self.txindex_to_vsize.iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.txindex,
|
||||
self.indexes_to_fee.sats.txindex.as_mut().unwrap().mut_vec(),
|
||||
self.indexes_to_fee.sats.txindex.as_ref().unwrap().vec(),
|
||||
|(txindex, fee, ..)| {
|
||||
let vsize = self
|
||||
.txindex_to_vsize
|
||||
.mut_vec()
|
||||
.double_unwrap_cached_get(txindex);
|
||||
|
||||
let vsize = txindex_to_vsize_iter.unwrap_get_inner(txindex);
|
||||
(txindex, Feerate::from((fee, vsize)))
|
||||
},
|
||||
exit,
|
||||
@@ -641,7 +631,7 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(self.txindex_to_weight.mut_vec()),
|
||||
Some(self.txindex_to_weight.vec()),
|
||||
)?;
|
||||
|
||||
self.indexes_to_tx_vsize.compute_rest(
|
||||
@@ -649,7 +639,7 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
Some(self.txindex_to_vsize.mut_vec()),
|
||||
Some(self.txindex_to_vsize.vec()),
|
||||
)?;
|
||||
|
||||
self.indexes_to_subsidy.compute_all(
|
||||
@@ -659,25 +649,25 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, indexer, indexes, starting_indexes, exit| {
|
||||
let indexer_vecs = indexer.mut_vecs();
|
||||
let mut txindex_to_first_outputindex_iter =
|
||||
indexer.vecs().txindex_to_first_outputindex.iter();
|
||||
let mut txindex_to_last_outputindex_iter =
|
||||
indexes.txindex_to_last_outputindex.iter();
|
||||
let mut outputindex_to_value_iter = indexer.vecs().outputindex_to_value.iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.height,
|
||||
indexer_vecs.height_to_first_txindex.mut_vec(),
|
||||
indexer.vecs().height_to_first_txindex.vec(),
|
||||
|(height, txindex, ..)| {
|
||||
let first_outputindex = indexer_vecs
|
||||
.txindex_to_first_outputindex
|
||||
.double_unwrap_cached_get(txindex)
|
||||
let first_outputindex = txindex_to_first_outputindex_iter
|
||||
.unwrap_get_inner(txindex)
|
||||
.unwrap_to_usize();
|
||||
let last_outputindex = indexes
|
||||
.txindex_to_last_outputindex
|
||||
.mut_vec()
|
||||
.double_unwrap_cached_get(txindex)
|
||||
let last_outputindex = txindex_to_last_outputindex_iter
|
||||
.unwrap_get_inner(txindex)
|
||||
.unwrap_to_usize();
|
||||
let mut sats = Sats::ZERO;
|
||||
(first_outputindex..=last_outputindex).for_each(|outputindex| {
|
||||
sats += indexer_vecs
|
||||
.outputindex_to_value
|
||||
.double_unwrap_cached_get(OutputIndex::from(outputindex));
|
||||
sats += outputindex_to_value_iter
|
||||
.unwrap_get_inner(OutputIndex::from(outputindex));
|
||||
});
|
||||
(height, sats)
|
||||
},
|
||||
@@ -693,22 +683,13 @@ impl Vecs {
|
||||
starting_indexes,
|
||||
exit,
|
||||
|vec, _, _, starting_indexes, exit| {
|
||||
let mut indexes_to_fee_sum_iter =
|
||||
self.indexes_to_fee.sats.height.unwrap_sum().iter();
|
||||
vec.compute_transform(
|
||||
starting_indexes.height,
|
||||
self.indexes_to_subsidy
|
||||
.sats
|
||||
.height
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.mut_vec(),
|
||||
self.indexes_to_subsidy.sats.height.as_ref().unwrap().vec(),
|
||||
|(height, subsidy, ..)| {
|
||||
let fees = self
|
||||
.indexes_to_fee
|
||||
.sats
|
||||
.height
|
||||
.unwrap_sum()
|
||||
.mut_vec()
|
||||
.double_unwrap_cached_get(height);
|
||||
let fees = indexes_to_fee_sum_iter.unwrap_get_inner(height);
|
||||
(height, subsidy.checked_sub(fees).unwrap())
|
||||
},
|
||||
exit,
|
||||
@@ -721,11 +702,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2aindex.vec(),
|
||||
indexer.vecs().p2aindex_to_p2abytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -735,11 +716,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2msindex.vec(),
|
||||
indexer.vecs().p2msindex_to_txindex.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -749,11 +730,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2pk33index.vec(),
|
||||
indexer.vecs().p2pk33index_to_p2pk33bytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -763,11 +744,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2pk65index.vec(),
|
||||
indexer.vecs().p2pk65index_to_p2pk65bytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -777,11 +758,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2pkhindex.vec(),
|
||||
indexer.vecs().p2pkhindex_to_p2pkhbytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -791,11 +772,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2shindex.vec(),
|
||||
indexer.vecs().p2shindex_to_p2shbytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -805,11 +786,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2trindex.vec(),
|
||||
indexer.vecs().p2trindex_to_p2trbytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -819,11 +800,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2wpkhindex.vec(),
|
||||
indexer.vecs().p2wpkhindex_to_p2wpkhbytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -833,11 +814,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_p2wshindex.vec(),
|
||||
indexer.vecs().p2wshindex_to_p2wshbytes.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -847,11 +828,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_opreturnindex.vec(),
|
||||
indexer.vecs().opreturnindex_to_txindex.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -861,14 +842,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_unknownoutputindex.vec(),
|
||||
indexer.vecs().unknownoutputindex_to_txindex.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
@@ -878,14 +856,11 @@ impl Vecs {
|
||||
indexes,
|
||||
starting_indexes,
|
||||
exit,
|
||||
|v, indexer, indexes, starting_indexes, exit| {
|
||||
|v, indexer, _, 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(),
|
||||
indexer.vecs().height_to_first_emptyoutputindex.vec(),
|
||||
indexer.vecs().emptyoutputindex_to_txindex.vec(),
|
||||
exit,
|
||||
)
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@ 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,
|
||||
StoredVecIterator, Version,
|
||||
StoredVecIterator, Value, Version,
|
||||
};
|
||||
use log::info;
|
||||
|
||||
@@ -108,7 +108,7 @@ where
|
||||
&self.inner
|
||||
}
|
||||
|
||||
pub fn mut_vec(&mut self) -> &mut StoredVec<I, T> {
|
||||
pub fn mut_vec(&mut self) -> &StoredVec<I, T> {
|
||||
&mut self.inner
|
||||
}
|
||||
|
||||
@@ -128,9 +128,9 @@ where
|
||||
self.inner.double_unwrap_cached_get(index)
|
||||
}
|
||||
|
||||
pub fn collect_inclusive_range(&self, from: I, to: I) -> Result<Vec<T>> {
|
||||
self.inner.collect_inclusive_range(from, to)
|
||||
}
|
||||
// pub fn collect_inclusive_range(&self, from: I, to: I) -> Result<Vec<T>> {
|
||||
// self.inner.collect_inclusive_range(from, to)
|
||||
// }
|
||||
|
||||
pub fn path(&self) -> &Path {
|
||||
self.inner.path()
|
||||
@@ -155,10 +155,14 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> StoredVecIterator<I, T> {
|
||||
self.into_iter()
|
||||
}
|
||||
|
||||
pub fn compute_range<A, F>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
other: &mut StoredVec<I, A>,
|
||||
other: &StoredVec<I, A>,
|
||||
mut t: F,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
@@ -211,7 +215,7 @@ where
|
||||
pub fn compute_inverse_more_to_less(
|
||||
&mut self,
|
||||
max_from: T,
|
||||
other: &mut StoredVec<T, I>,
|
||||
other: &StoredVec<T, I>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
@@ -245,8 +249,8 @@ where
|
||||
pub fn compute_inverse_less_to_more(
|
||||
&mut self,
|
||||
max_from: T,
|
||||
first_indexes: &mut StoredVec<T, I>,
|
||||
last_indexes: &mut StoredVec<T, I>,
|
||||
first_indexes: &StoredVec<T, I>,
|
||||
last_indexes: &StoredVec<T, I>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
@@ -257,13 +261,15 @@ where
|
||||
Version::ZERO + self.version() + first_indexes.version() + last_indexes.version(),
|
||||
)?;
|
||||
|
||||
let mut last_indexes_iter = last_indexes.iter();
|
||||
|
||||
let index = max_from.min(T::from(self.len()));
|
||||
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()?;
|
||||
let last_index = last_indexes_iter.get(value).unwrap().1.to_usize()?;
|
||||
(first_index..=last_index)
|
||||
.try_for_each(|index| self.forced_push_at(I::from(index), value, exit))
|
||||
})?;
|
||||
@@ -274,7 +280,7 @@ where
|
||||
pub fn compute_last_index_from_first(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
first_indexes: &mut StoredVec<I, T>,
|
||||
first_indexes: &StoredVec<I, T>,
|
||||
final_len: usize,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
@@ -310,11 +316,11 @@ where
|
||||
self.safe_flush(exit)
|
||||
}
|
||||
|
||||
pub fn compute_count_from_indexes<T2>(
|
||||
pub fn compute_count_from_indexes<T2, T3>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
first_indexes: &mut StoredVec<I, T2>,
|
||||
last_indexes: &mut StoredVec<I, T2>,
|
||||
first_indexes: &StoredVec<I, T2>,
|
||||
other_to_else: &StoredVec<T2, T3>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
@@ -327,16 +333,17 @@ where
|
||||
+ TryInto<T>
|
||||
+ Default,
|
||||
<T2 as TryInto<T>>::Error: error::Error + 'static,
|
||||
T3: StoredType,
|
||||
{
|
||||
let opt: Option<Box<dyn FnMut(T2) -> bool>> = None;
|
||||
self.compute_filtered_count_from_indexes_(max_from, first_indexes, last_indexes, opt, exit)
|
||||
self.compute_filtered_count_from_indexes_(max_from, first_indexes, other_to_else, opt, exit)
|
||||
}
|
||||
|
||||
pub fn compute_filtered_count_from_indexes<T2, F>(
|
||||
pub fn compute_filtered_count_from_indexes<T2, T3, F>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
first_indexes: &mut StoredVec<I, T2>,
|
||||
last_indexes: &mut StoredVec<I, T2>,
|
||||
first_indexes: &StoredVec<I, T2>,
|
||||
other_to_else: &StoredVec<T2, T3>,
|
||||
filter: F,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
@@ -350,22 +357,23 @@ where
|
||||
+ TryInto<T>
|
||||
+ Default,
|
||||
<T2 as TryInto<T>>::Error: error::Error + 'static,
|
||||
T3: StoredType,
|
||||
F: FnMut(T2) -> bool,
|
||||
{
|
||||
self.compute_filtered_count_from_indexes_(
|
||||
max_from,
|
||||
first_indexes,
|
||||
last_indexes,
|
||||
other_to_else,
|
||||
Some(Box::new(filter)),
|
||||
exit,
|
||||
)
|
||||
}
|
||||
|
||||
fn compute_filtered_count_from_indexes_<T2>(
|
||||
fn compute_filtered_count_from_indexes_<T2, T3>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
first_indexes: &mut StoredVec<I, T2>,
|
||||
last_indexes: &mut StoredVec<I, T2>,
|
||||
first_indexes: &StoredVec<I, T2>,
|
||||
other_to_else: &StoredVec<T2, T3>,
|
||||
mut filter: Option<Box<dyn FnMut(T2) -> bool + '_>>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
@@ -378,19 +386,25 @@ where
|
||||
+ CheckedSub<T2>
|
||||
+ TryInto<T>
|
||||
+ Default,
|
||||
T3: StoredType,
|
||||
<T2 as TryInto<T>>::Error: error::Error + 'static,
|
||||
{
|
||||
self.validate_computed_version_or_reset_file(
|
||||
Version::ZERO + self.version() + first_indexes.version() + last_indexes.version(),
|
||||
Version::ZERO + self.version() + first_indexes.version(), // + last_indexes.version(),
|
||||
)?;
|
||||
|
||||
let mut other_iter = first_indexes.iter();
|
||||
let index = max_from.min(I::from(self.len()));
|
||||
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 end = other_iter
|
||||
.get(i + 1)
|
||||
.map(|(_, v)| v.into_inner().unwrap_to_usize())
|
||||
.unwrap_or_else(|| other_to_else.len());
|
||||
|
||||
let range = first_index.unwrap_to_usize()..end;
|
||||
let count = if let Some(filter) = filter.as_mut() {
|
||||
range.into_iter().filter(|i| filter(T2::from(*i))).count()
|
||||
} else {
|
||||
@@ -405,8 +419,8 @@ where
|
||||
pub fn compute_is_first_ordered<A>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
self_to_other: &mut StoredVec<I, A>,
|
||||
other_to_self: &mut StoredVec<A, I>,
|
||||
self_to_other: &StoredVec<I, A>,
|
||||
other_to_self: &StoredVec<A, I>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
@@ -418,6 +432,7 @@ where
|
||||
Version::ZERO + self.version() + self_to_other.version() + other_to_self.version(),
|
||||
)?;
|
||||
|
||||
let mut other_to_self_iter = other_to_self.iter();
|
||||
let index = max_from.min(I::from(self.len()));
|
||||
self_to_other
|
||||
.iter()
|
||||
@@ -425,7 +440,14 @@ where
|
||||
.try_for_each(|(i, other)| {
|
||||
self.forced_push_at(
|
||||
i,
|
||||
T::from(other_to_self.double_unwrap_cached_get(other.into_inner()) == i),
|
||||
T::from(
|
||||
other_to_self_iter
|
||||
.get(other.into_inner())
|
||||
.unwrap()
|
||||
.1
|
||||
.into_inner()
|
||||
== i,
|
||||
),
|
||||
exit,
|
||||
)
|
||||
})?;
|
||||
@@ -436,9 +458,9 @@ where
|
||||
pub fn compute_sum_from_indexes<T2>(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
first_indexes: &mut StoredVec<I, T2>,
|
||||
last_indexes: &mut StoredVec<I, T2>,
|
||||
source: &mut StoredVec<T2, T>,
|
||||
first_indexes: &StoredVec<I, T2>,
|
||||
last_indexes: &StoredVec<I, T2>,
|
||||
source: &StoredVec<T2, T>,
|
||||
exit: &Exit,
|
||||
) -> Result<()>
|
||||
where
|
||||
@@ -449,16 +471,18 @@ where
|
||||
Version::ZERO + self.version() + first_indexes.version() + last_indexes.version(),
|
||||
)?;
|
||||
|
||||
let mut last_indexes_iter = last_indexes.iter();
|
||||
let mut source_iter = source.iter();
|
||||
let index = max_from.min(I::from(self.len()));
|
||||
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 last_index = last_indexes_iter.get(i).unwrap().1.into_inner();
|
||||
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));
|
||||
sum = sum.clone() + source_iter.get(T2::from(i)).unwrap().1.into_inner();
|
||||
});
|
||||
self.forced_push_at(i, sum, exit)
|
||||
})?;
|
||||
@@ -474,7 +498,7 @@ where
|
||||
pub fn compute_from_sats(
|
||||
&mut self,
|
||||
max_from: I,
|
||||
sats: &mut StoredVec<I, Sats>,
|
||||
sats: &StoredVec<I, Sats>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.validate_computed_version_or_reset_file(
|
||||
@@ -497,20 +521,21 @@ impl EagerVec<Height, Dollars> {
|
||||
pub fn compute_from_bitcoin(
|
||||
&mut self,
|
||||
max_from: Height,
|
||||
bitcoin: &mut StoredVec<Height, Bitcoin>,
|
||||
price: &mut StoredVec<Height, Close<Dollars>>,
|
||||
bitcoin: &StoredVec<Height, Bitcoin>,
|
||||
price: &StoredVec<Height, Close<Dollars>>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.validate_computed_version_or_reset_file(
|
||||
Version::ZERO + self.version() + bitcoin.version(),
|
||||
)?;
|
||||
|
||||
let mut price_iter = price.iter();
|
||||
let index = max_from.min(Height::from(self.len()));
|
||||
bitcoin
|
||||
.iter()
|
||||
.skip(index.unwrap_to_usize())
|
||||
.try_for_each(|(i, bitcoin)| {
|
||||
let dollars = price.double_unwrap_cached_get(i);
|
||||
let dollars = price_iter.get(i).unwrap().1.into_inner();
|
||||
let (i, v) = (i, *dollars * bitcoin.into_inner());
|
||||
self.forced_push_at(i, v, exit)
|
||||
})?;
|
||||
@@ -523,22 +548,24 @@ impl EagerVec<TxIndex, Dollars> {
|
||||
pub fn compute_from_bitcoin(
|
||||
&mut self,
|
||||
max_from: TxIndex,
|
||||
bitcoin: &mut StoredVec<TxIndex, Bitcoin>,
|
||||
i_to_height: &mut StoredVec<TxIndex, Height>,
|
||||
price: &mut StoredVec<Height, Close<Dollars>>,
|
||||
bitcoin: &StoredVec<TxIndex, Bitcoin>,
|
||||
i_to_height: &StoredVec<TxIndex, Height>,
|
||||
price: &StoredVec<Height, Close<Dollars>>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.validate_computed_version_or_reset_file(
|
||||
Version::ZERO + self.version() + bitcoin.version(),
|
||||
)?;
|
||||
|
||||
let mut i_to_height_iter = i_to_height.iter();
|
||||
let mut price_iter = price.iter();
|
||||
let index = max_from.min(TxIndex::from(self.len()));
|
||||
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 height = i_to_height_iter.get(i).unwrap().1.into_inner();
|
||||
let dollars = price_iter.get(height).unwrap().1.into_inner();
|
||||
let (i, v) = (i, *dollars * bitcoin.into_inner());
|
||||
self.forced_push_at(i, v, exit)
|
||||
})?;
|
||||
@@ -559,3 +586,16 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, I, T> IntoIterator for &'a EagerVec<I, T>
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
use core::error;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
fmt::Debug,
|
||||
ops::Add,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
||||
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,
|
||||
};
|
||||
use log::info;
|
||||
|
||||
const ONE_KIB: usize = 1024;
|
||||
const ONE_MIB: usize = ONE_KIB * ONE_KIB;
|
||||
const MAX_CACHE_SIZE: usize = 210 * ONE_MIB;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum Mode {
|
||||
Lazy,
|
||||
Eager,
|
||||
}
|
||||
use brk_vec::{DynamicVec, GenericVec, StoredIndex, StoredType, StoredVec, Version};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LazyVec<I, T>
|
||||
@@ -58,9 +37,9 @@ where
|
||||
self.inner.double_unwrap_cached_get(index)
|
||||
}
|
||||
|
||||
pub fn collect_inclusive_range(&self, from: I, to: I) -> Result<Vec<T>> {
|
||||
self.inner.collect_inclusive_range(from, to)
|
||||
}
|
||||
// pub fn collect_inclusive_range(&self, from: I, to: I) -> Result<Vec<T>> {
|
||||
// self.inner.collect_inclusive_range(from, to)
|
||||
// }
|
||||
}
|
||||
|
||||
impl<I, T> Clone for LazyVec<I, T>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
mod _type;
|
||||
mod eager;
|
||||
// mod lazy;
|
||||
mod lazy;
|
||||
|
||||
pub use _type::*;
|
||||
pub use eager::*;
|
||||
// pub use lazy::*;
|
||||
pub use lazy::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum Mode {
|
||||
Lazy,
|
||||
Eager,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user