mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-16 13:38:12 -07:00
global: utxos part 8
This commit is contained in:
@@ -36,7 +36,7 @@ use super::{BlockState, Transacted};
|
||||
pub struct Outputs<T> {
|
||||
pub all: T,
|
||||
pub by_term: OutputsByTerm<T>,
|
||||
// pub by_up_to: OutputsByUpTo<T>,
|
||||
pub by_up_to: OutputsByUpTo<T>,
|
||||
pub by_from: OutputsByFrom<T>,
|
||||
pub by_range: OutputsByRange<T>,
|
||||
pub by_epoch: OutputsByEpoch<T>,
|
||||
@@ -51,7 +51,7 @@ impl<T> Outputs<T> {
|
||||
[&mut self.all]
|
||||
.into_iter()
|
||||
.chain(self.by_term.as_mut_vec())
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_from.as_mut_vec())
|
||||
.chain(self.by_range.as_mut_vec())
|
||||
.chain(self.by_epoch.as_mut_vec())
|
||||
@@ -73,7 +73,7 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
self.by_term
|
||||
.as_mut_vec()
|
||||
.into_par_iter()
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_from.as_mut_vec())
|
||||
.chain(self.by_range.as_mut_vec())
|
||||
.for_each(|(filter, v)| {
|
||||
@@ -126,7 +126,7 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
.by_term
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
// .chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_up_to.as_mut_vec())
|
||||
.chain(self.by_from.as_mut_vec())
|
||||
.chain(self.by_range.as_mut_vec())
|
||||
.chain(self.by_epoch.as_mut_vec())
|
||||
@@ -187,7 +187,7 @@ impl Outputs<(OutputFilter, vecs::utxos::cohort::Vecs)> {
|
||||
// Skip from and range as can't receive in the past
|
||||
]
|
||||
.into_iter()
|
||||
// .chain(self.by_up_to.as_mut_vec().map(|(_, v)| v))
|
||||
.chain(self.by_up_to.as_mut_vec().map(|(_, v)| v))
|
||||
.for_each(|v| {
|
||||
v.state.increment(&supply_state, price);
|
||||
});
|
||||
@@ -222,7 +222,7 @@ impl<T> Outputs<(OutputFilter, T)> {
|
||||
[&self.all.1]
|
||||
.into_iter()
|
||||
.chain(self.by_term.vecs())
|
||||
// .chain(self.by_up_to.vecs())
|
||||
.chain(self.by_up_to.vecs())
|
||||
.chain(self.by_from.vecs())
|
||||
.chain(self.by_range.vecs())
|
||||
.chain(self.by_epoch.vecs())
|
||||
@@ -238,7 +238,7 @@ impl<T> From<Outputs<T>> for Outputs<(OutputFilter, T)> {
|
||||
Self {
|
||||
all: (OutputFilter::All, value.all),
|
||||
by_term: OutputsByTerm::from(value.by_term),
|
||||
// by_up_to: OutputsByUpTo::from(value.by_up_to),
|
||||
by_up_to: OutputsByUpTo::from(value.by_up_to),
|
||||
by_from: OutputsByFrom::from(value.by_from),
|
||||
by_range: OutputsByRange::from(value.by_range),
|
||||
by_epoch: OutputsByEpoch::from(value.by_epoch),
|
||||
|
||||
@@ -117,7 +117,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("realized_price"),
|
||||
true,
|
||||
VERSION + Version::ZERO + version,
|
||||
VERSION + Version::new(2) + version,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
@@ -128,7 +128,7 @@ impl Vecs {
|
||||
path,
|
||||
&suffix("realized_price"),
|
||||
false,
|
||||
VERSION + Version::ZERO,
|
||||
VERSION + Version::new(2) + version,
|
||||
compressed,
|
||||
StorableVecGeneatorOptions::default().add_last(),
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ use rayon::prelude::*;
|
||||
|
||||
use crate::states::{
|
||||
BlockState, OutputFilter, Outputs, OutputsByEpoch, OutputsByFrom, OutputsByRange,
|
||||
OutputsBySize, OutputsBySpendableType, OutputsByTerm, SupplyState, Transacted,
|
||||
OutputsBySize, OutputsBySpendableType, OutputsByTerm, OutputsByUpTo, SupplyState, Transacted,
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -101,152 +101,152 @@ impl Vecs {
|
||||
fetched,
|
||||
)?,
|
||||
},
|
||||
// by_up_to: OutputsByUpTo {
|
||||
// _1d: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_1d"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _1w: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_1w"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _1m: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_1m"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _2m: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_2m"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _3m: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_3m"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _4m: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_4m"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _5m: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_5m"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _6m: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_6m"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _1y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_1y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _2y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_2y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _3y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_3y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _4y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_4y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _5y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_5y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _6y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_6y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _7y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_7y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _8y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_8y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _10y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_10y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// _15y: cohort::Vecs::forced_import(
|
||||
// path,
|
||||
// Some("up_to_15y"),
|
||||
// _computation,
|
||||
// compressed,
|
||||
// VERSION + Version::ZERO,
|
||||
// fetched,
|
||||
// )?,
|
||||
// },
|
||||
by_up_to: OutputsByUpTo {
|
||||
_1d: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_1d"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_1w: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_1w"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_1m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_1m"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_2m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_2m"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_3m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_3m"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_4m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_4m"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_5m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_5m"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_6m: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_6m"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_1y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_1y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_2y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_2y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_3y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_3y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_4y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_4y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_5y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_5y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_6y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_6y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_7y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_7y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_8y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_8y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_10y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_10y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
_15y: cohort::Vecs::forced_import(
|
||||
path,
|
||||
Some("up_to_15y"),
|
||||
_computation,
|
||||
compressed,
|
||||
VERSION + Version::ZERO,
|
||||
fetched,
|
||||
)?,
|
||||
},
|
||||
by_from: OutputsByFrom {
|
||||
_1d: cohort::Vecs::forced_import(
|
||||
path,
|
||||
@@ -1191,14 +1191,18 @@ impl Vecs {
|
||||
|
||||
let mut flat_vecs_ = self.utxos_vecs.as_mut_vec();
|
||||
|
||||
info!("Flushing...");
|
||||
|
||||
// Flush rest of values
|
||||
flat_vecs_
|
||||
.iter_mut()
|
||||
.par_iter_mut()
|
||||
.try_for_each(|(_, v)| v.safe_flush_height_vecs(exit))?;
|
||||
self.height_to_unspendable_supply.safe_flush(exit)?;
|
||||
|
||||
info!("Computing rest...");
|
||||
|
||||
// Compute other vecs from height vecs
|
||||
flat_vecs_.iter_mut().try_for_each(|(_, v)| {
|
||||
flat_vecs_.par_iter_mut().try_for_each(|(_, v)| {
|
||||
v.compute_rest(indexer, indexes, fetched, starting_indexes, exit)
|
||||
})?;
|
||||
self.indexes_to_unspendable_supply.compute_rest(
|
||||
@@ -1210,6 +1214,8 @@ impl Vecs {
|
||||
Some(&self.height_to_unspendable_supply),
|
||||
)?;
|
||||
|
||||
info!("Chain state...");
|
||||
|
||||
// Save chain state
|
||||
self.chain_state.truncate_if_needed(Height::ZERO)?;
|
||||
mem::take(&mut chain_state)
|
||||
|
||||
Reference in New Issue
Block a user