Skip to content

Commit

Permalink
pos/epoched: keep 2 past epochs of data by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Jul 18, 2023
1 parent f61b635 commit 670f7e4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions proof_of_stake/src/epoched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ pub const LAST_UPDATE_SUB_KEY: &str = "last_update";
/// Sub-key for an epoched data structure's oldest epoch with some data
pub const OLDEST_EPOCH_SUB_KEY: &str = "oldest_epoch";

/// Default number of past epochs to keep.
const DEFAULT_NUM_PAST_EPOCHS: u64 = 2;

/// Discrete epoched data handle
pub struct Epoched<
Data,
FutureEpochs,
const NUM_PAST_EPOCHS: u64 = 0,
const NUM_PAST_EPOCHS: u64 = DEFAULT_NUM_PAST_EPOCHS,
SON = collections::Simple,
> {
storage_prefix: storage::Key,
Expand All @@ -38,8 +41,11 @@ pub struct Epoched<
}

/// Discrete epoched data handle with nested lazy structure
pub type NestedEpoched<Data, FutureEpochs, const NUM_PAST_EPOCHS: u64 = 0> =
Epoched<Data, FutureEpochs, NUM_PAST_EPOCHS, collections::Nested>;
pub type NestedEpoched<
Data,
FutureEpochs,
const NUM_PAST_EPOCHS: u64 = DEFAULT_NUM_PAST_EPOCHS,
> = Epoched<Data, FutureEpochs, NUM_PAST_EPOCHS, collections::Nested>;

/// Delta epoched data handle
pub struct EpochedDelta<Data, FutureEpochs, const NUM_PAST_EPOCHS: u64> {
Expand Down

0 comments on commit 670f7e4

Please sign in to comment.