Skip to content

Commit

Permalink
[Sui Framework] Expose getter for current epoch number
Browse files Browse the repository at this point in the history
Also expose a test-only function for advancing the epoch number. This is useful for contracts that need time, at least until we have a more fine-grained timestamping scheme.
  • Loading branch information
sblackshear committed May 16, 2022
1 parent be23ba0 commit 99426cd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sui_programmability/framework/sources/Governance/SuiSystem.move
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,15 @@ module Sui::SuiSystem {
// remaining balance in `computation_reward`. All of these go to the storage fund.
Balance::join(&mut self.storage_fund, computation_reward)
}

/// Return the current epoch number. Useful for applications that need a coarse-grained concept of time,
/// since epochs are ever-increasing and epoch changes are intended to happen every 24 hours.
public fun epoch(self: &SuiSystemState): u64 {
self.epoch
}

#[test_only]
public fun set_epoch_for_testing(self: &mut SuiSystemState, epoch_num: u64) {
self.epoch = epoch_num
}
}

0 comments on commit 99426cd

Please sign in to comment.