mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-01 18:53:38 -07:00
global: snapshot
This commit is contained in:
@@ -100,8 +100,10 @@ impl<R: RealizedOps> CohortState<R> {
|
||||
}
|
||||
|
||||
pub(crate) fn reset_single_iteration_values(&mut self) {
|
||||
self.sent = Sats::ZERO;
|
||||
self.satdays_destroyed = Sats::ZERO;
|
||||
if R::TRACK_ACTIVITY {
|
||||
self.sent = Sats::ZERO;
|
||||
self.satdays_destroyed = Sats::ZERO;
|
||||
}
|
||||
self.realized.reset_single_iteration_values();
|
||||
}
|
||||
|
||||
@@ -198,8 +200,10 @@ impl<R: RealizedOps> CohortState<R> {
|
||||
pre: &SendPrecomputed,
|
||||
) {
|
||||
self.supply -= supply;
|
||||
self.sent += pre.sats;
|
||||
self.satdays_destroyed += pre.age.satdays_destroyed(pre.sats);
|
||||
if R::TRACK_ACTIVITY {
|
||||
self.sent += pre.sats;
|
||||
self.satdays_destroyed += pre.age.satdays_destroyed(pre.sats);
|
||||
}
|
||||
|
||||
self.realized
|
||||
.send(pre.sats, pre.current_ps, pre.prev_ps, pre.ath_ps, pre.prev_investor_cap);
|
||||
@@ -241,8 +245,10 @@ impl<R: RealizedOps> CohortState<R> {
|
||||
self.supply -= supply;
|
||||
|
||||
if supply.value > Sats::ZERO {
|
||||
self.sent += supply.value;
|
||||
self.satdays_destroyed += age.satdays_destroyed(supply.value);
|
||||
if R::TRACK_ACTIVITY {
|
||||
self.sent += supply.value;
|
||||
self.satdays_destroyed += age.satdays_destroyed(supply.value);
|
||||
}
|
||||
|
||||
let sats = supply.value;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ use brk_types::{Cents, CentsSats, CentsSquaredSats, Sats};
|
||||
|
||||
/// Trait for realized state operations, implemented by Minimal, Core, and Full variants.
|
||||
pub trait RealizedOps: Default + Clone + Send + Sync + 'static {
|
||||
const TRACK_ACTIVITY: bool = false;
|
||||
fn cap(&self) -> Cents;
|
||||
fn profit(&self) -> Cents;
|
||||
fn loss(&self) -> Cents;
|
||||
@@ -159,6 +160,8 @@ pub struct CoreRealizedState {
|
||||
}
|
||||
|
||||
impl RealizedOps for CoreRealizedState {
|
||||
const TRACK_ACTIVITY: bool = true;
|
||||
|
||||
#[inline]
|
||||
fn cap(&self) -> Cents {
|
||||
self.minimal.cap()
|
||||
@@ -273,6 +276,8 @@ pub struct RealizedState {
|
||||
}
|
||||
|
||||
impl RealizedOps for RealizedState {
|
||||
const TRACK_ACTIVITY: bool = true;
|
||||
|
||||
#[inline]
|
||||
fn cap(&self) -> Cents {
|
||||
self.core.cap()
|
||||
|
||||
Reference in New Issue
Block a user