Skip to content

Commit

Permalink
Merge branch 'origin/tomas/pos-data-history' (#1733)
Browse files Browse the repository at this point in the history
* origin/tomas/pos-data-history:
  changelog: add #1733
  pos/epoched: keep 2 past epochs of data by default
  • Loading branch information
Fraccaman committed Jul 21, 2023
2 parents d5af059 + 641f9e0 commit e956a37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/miscellaneous/1733-pos-data-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- PoS: Keep the data for last two epochs by default.
([\#1733](https://github.com/anoma/namada/pull/1733))
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 e956a37

Please sign in to comment.