global: snapshot

This commit is contained in:
nym21
2026-02-27 18:48:37 +01:00
parent 6845ad409b
commit d5ec291579
62 changed files with 1960 additions and 1449 deletions

View File

@@ -30,8 +30,8 @@ use super::{
vecs::Vecs,
},
BIP30_DUPLICATE_HEIGHT_1, BIP30_DUPLICATE_HEIGHT_2, BIP30_ORIGINAL_HEIGHT_1,
BIP30_ORIGINAL_HEIGHT_2, ComputeContext, FLUSH_INTERVAL, TxInReaders, TxOutReaders,
IndexToTxIndexBuf, VecsReaders,
BIP30_ORIGINAL_HEIGHT_2, ComputeContext, FLUSH_INTERVAL, IndexToTxIndexBuf, TxInReaders,
TxOutReaders, VecsReaders,
};
/// Process all blocks from starting_height to last_height.
@@ -278,7 +278,7 @@ pub(crate) fn process_blocks(
let outputs_handle = scope.spawn(|| {
// Process outputs (receive)
process_outputs(
&txoutindex_to_txindex,
txoutindex_to_txindex,
&txoutdata_vec,
&first_addressindexes,
&cache,

View File

@@ -82,6 +82,7 @@ impl ActivityMetrics {
/// Get minimum length across height-indexed vectors.
pub(crate) fn min_len(&self) -> usize {
self.sent
.base
.sats
.height
.len()
@@ -97,7 +98,7 @@ impl ActivityMetrics {
satblocks_destroyed: Sats,
satdays_destroyed: Sats,
) -> Result<()> {
self.sent.sats.height.truncate_push(height, sent)?;
self.sent.base.sats.height.truncate_push(height, sent)?;
self.satblocks_destroyed
.truncate_push(height, satblocks_destroyed)?;
self.satdays_destroyed
@@ -108,7 +109,7 @@ impl ActivityMetrics {
/// Returns a parallel iterator over all vecs for parallel writing.
pub(crate) fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut dyn AnyStoredVec> {
vec![
&mut self.sent.sats.height as &mut dyn AnyStoredVec,
&mut self.sent.base.sats.height as &mut dyn AnyStoredVec,
&mut self.satblocks_destroyed as &mut dyn AnyStoredVec,
&mut self.satdays_destroyed as &mut dyn AnyStoredVec,
]
@@ -128,11 +129,11 @@ impl ActivityMetrics {
others: &[&Self],
exit: &Exit,
) -> Result<()> {
self.sent.sats.height.compute_sum_of_others(
self.sent.base.sats.height.compute_sum_of_others(
starting_indexes.height,
&others
.iter()
.map(|v| &v.sent.sats.height)
.map(|v| &v.sent.base.sats.height)
.collect::<Vec<_>>(),
exit,
)?;
@@ -168,8 +169,8 @@ impl ActivityMetrics {
self.sent_14d_ema.compute_rolling_average(
starting_indexes.height,
&blocks.count.height_2w_ago,
&self.sent.sats.height,
&self.sent.usd.height,
&self.sent.base.sats.height,
&self.sent.base.usd.height,
exit,
)?;

View File

@@ -582,8 +582,8 @@ impl RealizedBase {
.min(self.loss_value_created.height.len())
.min(self.loss_value_destroyed.height.len())
.min(self.peak_regret.height.len())
.min(self.sent_in_profit.sats.height.len())
.min(self.sent_in_loss.sats.height.len())
.min(self.sent_in_profit.base.sats.height.len())
.min(self.sent_in_loss.base.sats.height.len())
}
/// Push realized state values to height-indexed vectors.
@@ -619,10 +619,12 @@ impl RealizedBase {
.height
.truncate_push(height, state.peak_regret().to_dollars())?;
self.sent_in_profit
.base
.sats
.height
.truncate_push(height, state.sent_in_profit())?;
self.sent_in_loss
.base
.sats
.height
.truncate_push(height, state.sent_in_loss())?;
@@ -644,8 +646,8 @@ impl RealizedBase {
&mut self.loss_value_created.height,
&mut self.loss_value_destroyed.height,
&mut self.peak_regret.height,
&mut self.sent_in_profit.sats.height,
&mut self.sent_in_loss.sats.height,
&mut self.sent_in_profit.base.sats.height,
&mut self.sent_in_loss.base.sats.height,
]
}
@@ -778,19 +780,19 @@ impl RealizedBase {
.collect::<Vec<_>>(),
exit,
)?;
self.sent_in_profit.sats.height.compute_sum_of_others(
self.sent_in_profit.base.sats.height.compute_sum_of_others(
starting_indexes.height,
&others
.iter()
.map(|v| &v.sent_in_profit.sats.height)
.map(|v| &v.sent_in_profit.base.sats.height)
.collect::<Vec<_>>(),
exit,
)?;
self.sent_in_loss.sats.height.compute_sum_of_others(
self.sent_in_loss.base.sats.height.compute_sum_of_others(
starting_indexes.height,
&others
.iter()
.map(|v| &v.sent_in_loss.sats.height)
.map(|v| &v.sent_in_loss.base.sats.height)
.collect::<Vec<_>>(),
exit,
)?;
@@ -1045,15 +1047,15 @@ impl RealizedBase {
self.sent_in_profit_14d_ema.compute_rolling_average(
starting_indexes.height,
&blocks.count.height_2w_ago,
&self.sent_in_profit.sats.height,
&self.sent_in_profit.usd.height,
&self.sent_in_profit.base.sats.height,
&self.sent_in_profit.base.usd.height,
exit,
)?;
self.sent_in_loss_14d_ema.compute_rolling_average(
starting_indexes.height,
&blocks.count.height_2w_ago,
&self.sent_in_loss.sats.height,
&self.sent_in_loss.usd.height,
&self.sent_in_loss.base.sats.height,
&self.sent_in_loss.base.usd.height,
exit,
)?;

View File

@@ -66,8 +66,8 @@ impl SupplyMetrics {
/// Returns a parallel iterator over all vecs for parallel writing.
pub(crate) fn par_iter_mut(&mut self) -> impl ParallelIterator<Item = &mut dyn AnyStoredVec> {
vec![
&mut self.total.sats.height as &mut dyn AnyStoredVec,
&mut self.total.usd.height as &mut dyn AnyStoredVec,
&mut self.total.base.sats.height as &mut dyn AnyStoredVec,
&mut self.total.base.usd.height as &mut dyn AnyStoredVec,
]
.into_par_iter()
}

View File

@@ -236,10 +236,10 @@ impl UnrealizedBase {
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
vec![
&mut self.supply_in_profit.sats.height as &mut dyn AnyStoredVec,
&mut self.supply_in_profit.usd.height as &mut dyn AnyStoredVec,
&mut self.supply_in_loss.sats.height as &mut dyn AnyStoredVec,
&mut self.supply_in_loss.usd.height as &mut dyn AnyStoredVec,
&mut self.supply_in_profit.base.sats.height as &mut dyn AnyStoredVec,
&mut self.supply_in_profit.base.usd.height as &mut dyn AnyStoredVec,
&mut self.supply_in_loss.base.sats.height as &mut dyn AnyStoredVec,
&mut self.supply_in_loss.base.usd.height as &mut dyn AnyStoredVec,
&mut self.unrealized_profit.height,
&mut self.unrealized_loss.height,
&mut self.invested_capital_in_profit.height,