mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -106,7 +106,7 @@ impl ActivityCountVecs {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.reactivated
|
||||
.height
|
||||
.len()
|
||||
@@ -197,10 +197,10 @@ impl AddressTypeToActivityCountVecs {
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.0
|
||||
.values()
|
||||
.map(|v| v.min_stateful_height())
|
||||
.map(|v| v.min_stateful_len())
|
||||
.min()
|
||||
.unwrap_or(0)
|
||||
}
|
||||
@@ -272,10 +272,10 @@ impl AddressActivityVecs {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.all
|
||||
.min_stateful_height()
|
||||
.min(self.by_addresstype.min_stateful_height())
|
||||
.min_stateful_len()
|
||||
.min(self.by_addresstype.min_stateful_len())
|
||||
}
|
||||
|
||||
pub(crate) fn par_iter_height_mut(
|
||||
|
||||
@@ -125,7 +125,7 @@ impl AddressTypeToAddrCountVecs {
|
||||
)?))
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.0.values().map(|v| v.height.len()).min().unwrap()
|
||||
}
|
||||
|
||||
@@ -181,8 +181,8 @@ impl AddrCountsVecs {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height(&self) -> usize {
|
||||
self.all.height.len().min(self.by_addresstype.min_stateful_height())
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.all.height.len().min(self.by_addresstype.min_stateful_len())
|
||||
}
|
||||
|
||||
pub(crate) fn par_iter_height_mut(
|
||||
|
||||
@@ -98,7 +98,7 @@ impl AddressCohorts {
|
||||
self.par_iter_mut().try_for_each(|v| {
|
||||
v.addr_count_delta.compute(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_1m_ago,
|
||||
&blocks.lookback._1m,
|
||||
&v.addr_count.height,
|
||||
exit,
|
||||
)
|
||||
@@ -141,9 +141,9 @@ impl AddressCohorts {
|
||||
}
|
||||
|
||||
/// Get minimum height from all separate cohorts' height-indexed vectors.
|
||||
pub(crate) fn min_separate_stateful_height_len(&self) -> Height {
|
||||
pub(crate) fn min_stateful_len(&self) -> Height {
|
||||
self.iter_separate()
|
||||
.map(|v| Height::from(v.min_stateful_height_len()))
|
||||
.map(|v| Height::from(v.min_stateful_len()))
|
||||
.min()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ impl Filtered for AddressCohortVecs {
|
||||
}
|
||||
|
||||
impl DynCohortVecs for AddressCohortVecs {
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.addr_count
|
||||
.height
|
||||
.len()
|
||||
.min(self.metrics.min_stateful_height_len())
|
||||
.min(self.metrics.min_stateful_len())
|
||||
}
|
||||
|
||||
fn reset_state_starting_height(&mut self) {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{blocks, prices};
|
||||
/// This trait enables heterogeneous cohort processing via trait objects.
|
||||
pub trait DynCohortVecs: Send + Sync {
|
||||
/// Get minimum length across height-indexed vectors written in block loop.
|
||||
fn min_stateful_height_len(&self) -> usize;
|
||||
fn min_stateful_len(&self) -> usize;
|
||||
|
||||
/// Reset the starting height for state tracking.
|
||||
fn reset_state_starting_height(&mut self);
|
||||
|
||||
@@ -712,10 +712,9 @@ impl UTXOCohorts<Rw> {
|
||||
.try_for_each(|v| v.write_state(height, cleanup))
|
||||
}
|
||||
|
||||
/// Get minimum height from all separate cohorts' + profitability + overlapping realized height-indexed vectors.
|
||||
pub(crate) fn min_separate_stateful_height_len(&self) -> Height {
|
||||
pub(crate) fn min_stateful_len(&self) -> Height {
|
||||
self.iter_separate()
|
||||
.map(|v| Height::from(v.min_stateful_height_len()))
|
||||
.map(|v| Height::from(v.min_stateful_len()))
|
||||
.chain(
|
||||
self.matured
|
||||
.iter()
|
||||
@@ -723,15 +722,15 @@ impl UTXOCohorts<Rw> {
|
||||
)
|
||||
.min()
|
||||
.unwrap_or_default()
|
||||
.min(Height::from(self.profitability.min_stateful_height_len()))
|
||||
.min(Height::from(self.profitability.min_stateful_len()))
|
||||
.min(Height::from(
|
||||
self.all.metrics.realized.min_stateful_height_len(),
|
||||
self.all.metrics.realized.min_stateful_len(),
|
||||
))
|
||||
.min(Height::from(
|
||||
self.sth.metrics.realized.min_stateful_height_len(),
|
||||
self.sth.metrics.realized.min_stateful_len(),
|
||||
))
|
||||
.min(Height::from(
|
||||
self.lth.metrics.realized.min_stateful_height_len(),
|
||||
self.lth.metrics.realized.min_stateful_len(),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ impl Filtered for UTXOCohortVecs<CoreCohortMetrics> {
|
||||
}
|
||||
|
||||
impl DynCohortVecs for UTXOCohortVecs<CoreCohortMetrics> {
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
self.metrics.min_stateful_height_len()
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.metrics.min_stateful_len()
|
||||
}
|
||||
|
||||
fn reset_state_starting_height(&mut self) {
|
||||
|
||||
@@ -18,8 +18,8 @@ impl Filtered for UTXOCohortVecs<MinimalCohortMetrics> {
|
||||
}
|
||||
|
||||
impl DynCohortVecs for UTXOCohortVecs<MinimalCohortMetrics> {
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
self.metrics.min_stateful_height_len()
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.metrics.min_stateful_len()
|
||||
}
|
||||
|
||||
fn reset_state_starting_height(&mut self) {
|
||||
|
||||
@@ -116,8 +116,8 @@ impl<M: CohortMetricsBase + Traversable> Filtered for UTXOCohortVecs<M> {
|
||||
}
|
||||
|
||||
impl<M: CohortMetricsBase + Traversable> DynCohortVecs for UTXOCohortVecs<M> {
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
self.metrics.min_stateful_height_len()
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.metrics.min_stateful_len()
|
||||
}
|
||||
|
||||
fn reset_state_starting_height(&mut self) {
|
||||
|
||||
@@ -14,8 +14,8 @@ impl Filtered for UTXOCohortVecs<TypeCohortMetrics> {
|
||||
}
|
||||
|
||||
impl DynCohortVecs for UTXOCohortVecs<TypeCohortMetrics> {
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
self.metrics.min_stateful_height_len()
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.metrics.min_stateful_len()
|
||||
}
|
||||
|
||||
fn reset_state_starting_height(&mut self) {
|
||||
|
||||
@@ -111,13 +111,13 @@ impl ActivityCore {
|
||||
) -> Result<()> {
|
||||
self.sent.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.sent.raw.height,
|
||||
exit,
|
||||
)?;
|
||||
self.coindays_destroyed.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.coindays_destroyed.raw.height,
|
||||
exit,
|
||||
)?;
|
||||
@@ -140,14 +140,14 @@ impl ActivityCore {
|
||||
|
||||
self.sent_in_profit.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.sent_in_profit.raw.sats.height,
|
||||
&self.sent_in_profit.raw.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.sent_in_loss.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.sent_in_loss.raw.sats.height,
|
||||
&self.sent_in_loss.raw.cents.height,
|
||||
exit,
|
||||
|
||||
@@ -55,14 +55,14 @@ impl CohortMetricsBase for AllCohortMetrics {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.supply
|
||||
.min_len()
|
||||
.min(self.outputs.min_len())
|
||||
.min(self.activity.min_len())
|
||||
.min(self.realized.min_stateful_height_len())
|
||||
.min(self.unrealized.min_stateful_height_len())
|
||||
.min(self.cost_basis.min_stateful_height_len())
|
||||
.min(self.realized.min_stateful_len())
|
||||
.min(self.unrealized.min_stateful_len())
|
||||
.min(self.cost_basis.min_stateful_len())
|
||||
}
|
||||
|
||||
fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
|
||||
@@ -37,13 +37,13 @@ impl CoreCohortMetrics {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.supply
|
||||
.min_len()
|
||||
.min(self.outputs.min_len())
|
||||
.min(self.activity.min_len())
|
||||
.min(self.realized.min_stateful_height_len())
|
||||
.min(self.unrealized.min_stateful_height_len())
|
||||
.min(self.realized.min_stateful_len())
|
||||
.min(self.unrealized.min_stateful_len())
|
||||
}
|
||||
|
||||
pub(crate) fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> {
|
||||
|
||||
@@ -51,14 +51,14 @@ impl CohortMetricsBase for ExtendedCohortMetrics {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.supply
|
||||
.min_len()
|
||||
.min(self.outputs.min_len())
|
||||
.min(self.activity.min_len())
|
||||
.min(self.realized.min_stateful_height_len())
|
||||
.min(self.unrealized.min_stateful_height_len())
|
||||
.min(self.cost_basis.min_stateful_height_len())
|
||||
.min(self.realized.min_stateful_len())
|
||||
.min(self.unrealized.min_stateful_len())
|
||||
.min(self.cost_basis.min_stateful_len())
|
||||
}
|
||||
|
||||
fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
|
||||
@@ -37,8 +37,8 @@ impl CohortMetricsBase for ExtendedAdjustedCohortMetrics {
|
||||
self.inner.validate_computed_versions(base_version)
|
||||
}
|
||||
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
self.inner.min_stateful_height_len()
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.inner.min_stateful_len()
|
||||
}
|
||||
|
||||
fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
|
||||
@@ -33,11 +33,11 @@ impl MinimalCohortMetrics {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.supply
|
||||
.min_len()
|
||||
.min(self.outputs.min_len())
|
||||
.min(self.realized.min_stateful_height_len())
|
||||
.min(self.realized.min_stateful_len())
|
||||
}
|
||||
|
||||
pub(crate) fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
|
||||
@@ -34,12 +34,12 @@ impl TypeCohortMetrics {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.supply
|
||||
.min_len()
|
||||
.min(self.outputs.min_len())
|
||||
.min(self.realized.min_stateful_height_len())
|
||||
.min(self.unrealized.min_stateful_height_len())
|
||||
.min(self.realized.min_stateful_len())
|
||||
.min(self.unrealized.min_stateful_len())
|
||||
}
|
||||
|
||||
pub(crate) fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
|
||||
@@ -44,7 +44,7 @@ impl CostBasis {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.min
|
||||
.cents
|
||||
.height
|
||||
|
||||
@@ -155,13 +155,13 @@ pub trait CohortMetricsBase: CohortMetricsState<Realized = RealizedState, CostBa
|
||||
|
||||
fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec>;
|
||||
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.supply()
|
||||
.min_len()
|
||||
.min(self.outputs().min_len())
|
||||
.min(self.activity().min_len())
|
||||
.min(self.realized().min_stateful_height_len())
|
||||
.min(self.unrealized().min_stateful_height_len())
|
||||
.min(self.realized().min_stateful_len())
|
||||
.min(self.unrealized().min_stateful_len())
|
||||
}
|
||||
|
||||
fn truncate_push(&mut self, height: Height, state: &CohortState<RealizedState, CostBasisData<WithCapital>>) -> Result<()> {
|
||||
|
||||
@@ -55,7 +55,7 @@ impl OutputsFull {
|
||||
) -> Result<()> {
|
||||
self.utxo_count_delta.compute(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_1m_ago,
|
||||
&blocks.lookback._1m,
|
||||
&self.base.utxo_count.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -72,7 +72,7 @@ pub struct ProfitabilityMetrics<M: StorageMode = Rw> {
|
||||
}
|
||||
|
||||
impl<M: StorageMode> ProfitabilityMetrics<M> {
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.range.iter()
|
||||
.chain(self.profit.iter())
|
||||
.chain(self.loss.iter())
|
||||
|
||||
@@ -74,8 +74,8 @@ impl RealizedCore {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
self.minimal.min_stateful_height_len()
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.minimal.min_stateful_len()
|
||||
}
|
||||
|
||||
pub(crate) fn truncate_push(&mut self, height: Height, state: &CohortState<impl RealizedOps, impl CostBasisOps>) -> Result<()> {
|
||||
@@ -149,14 +149,14 @@ impl RealizedCore {
|
||||
|
||||
self.cap_delta.compute(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_1m_ago,
|
||||
&blocks.lookback._1m,
|
||||
&self.minimal.cap.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.net_pnl.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.net_pnl.raw.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -263,10 +263,11 @@ impl RealizedFull {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
self.core
|
||||
.min_stateful_height_len()
|
||||
.min(self.profit.value_created.height.len())
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.profit
|
||||
.value_created
|
||||
.height
|
||||
.len()
|
||||
.min(self.profit.value_destroyed.height.len())
|
||||
.min(self.loss.value_created.height.len())
|
||||
.min(self.loss.value_destroyed.height.len())
|
||||
@@ -541,7 +542,7 @@ impl RealizedFull {
|
||||
// Net PnL delta (1m base + 24h/1w/1y extended)
|
||||
self.net_pnl.delta.compute(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_1m_ago,
|
||||
&blocks.lookback._1m,
|
||||
&self.net_pnl.cumulative.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -69,7 +69,7 @@ impl RealizedMinimal {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.cap
|
||||
.cents
|
||||
.height
|
||||
@@ -129,25 +129,25 @@ impl RealizedMinimal {
|
||||
) -> Result<()> {
|
||||
self.profit.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.profit.raw.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.loss.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.loss.raw.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.sopr.value_created.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.sopr.value_created.raw.height,
|
||||
exit,
|
||||
)?;
|
||||
self.sopr.value_destroyed.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.sopr.value_destroyed.raw.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::{blocks, distribution::state::{WithCapital, CohortState, CostBasisDat
|
||||
pub trait RealizedLike: Send + Sync {
|
||||
fn as_core(&self) -> &RealizedCore;
|
||||
fn as_core_mut(&mut self) -> &mut RealizedCore;
|
||||
fn min_stateful_height_len(&self) -> usize;
|
||||
fn min_stateful_len(&self) -> usize;
|
||||
fn truncate_push(&mut self, height: Height, state: &CohortState<RealizedState, CostBasisData<WithCapital>>) -> Result<()>;
|
||||
fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()>;
|
||||
fn compute_from_stateful(
|
||||
@@ -36,7 +36,7 @@ pub trait RealizedLike: Send + Sync {
|
||||
impl RealizedLike for RealizedCore {
|
||||
fn as_core(&self) -> &RealizedCore { self }
|
||||
fn as_core_mut(&mut self) -> &mut RealizedCore { self }
|
||||
fn min_stateful_height_len(&self) -> usize { self.min_stateful_height_len() }
|
||||
fn min_stateful_len(&self) -> usize { self.min_stateful_len() }
|
||||
fn truncate_push(&mut self, height: Height, state: &CohortState<RealizedState, CostBasisData<WithCapital>>) -> Result<()> {
|
||||
self.truncate_push(height, state)
|
||||
}
|
||||
@@ -51,7 +51,7 @@ impl RealizedLike for RealizedCore {
|
||||
impl RealizedLike for RealizedFull {
|
||||
fn as_core(&self) -> &RealizedCore { &self.core }
|
||||
fn as_core_mut(&mut self) -> &mut RealizedCore { &mut self.core }
|
||||
fn min_stateful_height_len(&self) -> usize { self.min_stateful_height_len() }
|
||||
fn min_stateful_len(&self) -> usize { self.min_stateful_len() }
|
||||
fn truncate_push(&mut self, height: Height, state: &CohortState<RealizedState, CostBasisData<WithCapital>>) -> Result<()> {
|
||||
self.truncate_push(height, state)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ impl SupplyFull {
|
||||
) -> Result<()> {
|
||||
self.delta.compute(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_1m_ago,
|
||||
&blocks.lookback._1m,
|
||||
&self.core.total.sats.height,
|
||||
exit,
|
||||
)
|
||||
|
||||
@@ -46,9 +46,9 @@ impl UnrealizedBase {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.core
|
||||
.min_stateful_height_len()
|
||||
.min_stateful_len()
|
||||
.min(self.invested_capital_in_profit_raw.len())
|
||||
.min(self.invested_capital_in_loss_raw.len())
|
||||
.min(self.investor_cap_in_profit_raw.len())
|
||||
|
||||
@@ -26,7 +26,7 @@ impl UnrealizedBasic {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.profit
|
||||
.raw
|
||||
.cents
|
||||
@@ -75,13 +75,13 @@ impl UnrealizedBasic {
|
||||
) -> Result<()> {
|
||||
self.profit.sum.compute_rolling_sum(
|
||||
max_from,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.profit.raw.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.loss.sum.compute_rolling_sum(
|
||||
max_from,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&blocks.lookback._24h,
|
||||
&self.loss.raw.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -49,8 +49,8 @@ impl UnrealizedCore {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
self.basic.min_stateful_height_len()
|
||||
pub(crate) fn min_stateful_len(&self) -> usize {
|
||||
self.basic.min_stateful_len()
|
||||
}
|
||||
|
||||
pub(crate) fn truncate_push(
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::{blocks, distribution::state::UnrealizedState, prices};
|
||||
pub trait UnrealizedLike: Send + Sync {
|
||||
fn as_base(&self) -> &UnrealizedBase;
|
||||
fn as_base_mut(&mut self) -> &mut UnrealizedBase;
|
||||
fn min_stateful_height_len(&self) -> usize;
|
||||
fn min_stateful_len(&self) -> usize;
|
||||
fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()>;
|
||||
fn compute_rest(
|
||||
&mut self,
|
||||
@@ -40,8 +40,8 @@ impl UnrealizedLike for UnrealizedBase {
|
||||
fn as_base_mut(&mut self) -> &mut UnrealizedBase {
|
||||
self
|
||||
}
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
self.min_stateful_height_len()
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.min_stateful_len()
|
||||
}
|
||||
fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()> {
|
||||
self.truncate_push(height, state)
|
||||
@@ -71,8 +71,8 @@ impl UnrealizedLike for UnrealizedFull {
|
||||
fn as_base_mut(&mut self) -> &mut UnrealizedBase {
|
||||
&mut self.inner
|
||||
}
|
||||
fn min_stateful_height_len(&self) -> usize {
|
||||
self.inner.min_stateful_height_len()
|
||||
fn min_stateful_len(&self) -> usize {
|
||||
self.inner.min_stateful_len()
|
||||
}
|
||||
fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()> {
|
||||
self.truncate_push_all(height, state)
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::{
|
||||
state::BlockState,
|
||||
},
|
||||
indexes, inputs,
|
||||
internal::{finalize_db, open_db, ComputedPerBlockCumulative},
|
||||
internal::{ComputedPerBlockCumulative, finalize_db, open_db},
|
||||
outputs, prices, transactions,
|
||||
};
|
||||
|
||||
@@ -240,16 +240,7 @@ impl Vecs {
|
||||
|
||||
// 1. Find minimum height we have data for across stateful vecs
|
||||
let current_height = Height::from(self.supply_state.len());
|
||||
debug!("supply_state.len={}", self.supply_state.len());
|
||||
debug!("utxo_cohorts.min={}", self.utxo_cohorts.min_separate_stateful_height_len());
|
||||
debug!("address_cohorts.min={}", self.address_cohorts.min_separate_stateful_height_len());
|
||||
debug!("address_indexes.min={}", self.any_address_indexes.min_stamped_height());
|
||||
debug!("addresses_data.min={}", self.addresses_data.min_stamped_height());
|
||||
debug!("addr_count.min={}", self.addr_count.min_stateful_height());
|
||||
debug!("empty_addr_count.min={}", self.empty_addr_count.min_stateful_height());
|
||||
debug!("address_activity.min={}", self.address_activity.min_stateful_height());
|
||||
debug!("coinblocks_destroyed.raw.height.len={}", self.coinblocks_destroyed.raw.height.len());
|
||||
let min_stateful = self.min_stateful_height_len();
|
||||
let min_stateful = self.min_stateful_len();
|
||||
|
||||
// 2. Determine start mode and recover/reset state
|
||||
// Clamp to starting_indexes.height to handle reorg (indexer may require earlier start)
|
||||
@@ -423,10 +414,8 @@ impl Vecs {
|
||||
)?;
|
||||
|
||||
// 6b. Compute address count sum (by addresstype → all)
|
||||
self.addr_count
|
||||
.compute_rest(starting_indexes, exit)?;
|
||||
self.empty_addr_count
|
||||
.compute_rest(starting_indexes, exit)?;
|
||||
self.addr_count.compute_rest(starting_indexes, exit)?;
|
||||
self.empty_addr_count.compute_rest(starting_indexes, exit)?;
|
||||
|
||||
// 6c. Compute total_addr_count = addr_count + empty_addr_count
|
||||
self.total_addr_count.compute(
|
||||
@@ -486,16 +475,47 @@ impl Vecs {
|
||||
}
|
||||
|
||||
/// Get minimum length across all height-indexed stateful vectors.
|
||||
fn min_stateful_height_len(&self) -> Height {
|
||||
fn min_stateful_len(&self) -> Height {
|
||||
debug!("supply_state.len={}", self.supply_state.len());
|
||||
debug!(
|
||||
"utxo_cohorts.min={}",
|
||||
self.utxo_cohorts.min_stateful_len()
|
||||
);
|
||||
debug!(
|
||||
"address_cohorts.min={}",
|
||||
self.address_cohorts.min_stateful_len()
|
||||
);
|
||||
debug!(
|
||||
"address_indexes.min={}",
|
||||
self.any_address_indexes.min_stamped_height()
|
||||
);
|
||||
debug!(
|
||||
"addresses_data.min={}",
|
||||
self.addresses_data.min_stamped_height()
|
||||
);
|
||||
debug!("addr_count.min={}", self.addr_count.min_stateful_len());
|
||||
debug!(
|
||||
"empty_addr_count.min={}",
|
||||
self.empty_addr_count.min_stateful_len()
|
||||
);
|
||||
debug!(
|
||||
"address_activity.min={}",
|
||||
self.address_activity.min_stateful_len()
|
||||
);
|
||||
debug!(
|
||||
"coinblocks_destroyed.raw.height.len={}",
|
||||
self.coinblocks_destroyed.raw.height.len()
|
||||
);
|
||||
|
||||
self.utxo_cohorts
|
||||
.min_separate_stateful_height_len()
|
||||
.min(self.address_cohorts.min_separate_stateful_height_len())
|
||||
.min_stateful_len()
|
||||
.min(self.address_cohorts.min_stateful_len())
|
||||
.min(Height::from(self.supply_state.len()))
|
||||
.min(self.any_address_indexes.min_stamped_height())
|
||||
.min(self.addresses_data.min_stamped_height())
|
||||
.min(Height::from(self.addr_count.min_stateful_height()))
|
||||
.min(Height::from(self.empty_addr_count.min_stateful_height()))
|
||||
.min(Height::from(self.address_activity.min_stateful_height()))
|
||||
.min(Height::from(self.addr_count.min_stateful_len()))
|
||||
.min(Height::from(self.empty_addr_count.min_stateful_len()))
|
||||
.min(Height::from(self.address_activity.min_stateful_len()))
|
||||
.min(Height::from(self.coinblocks_destroyed.raw.height.len()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user