Skip to content

Commit

Permalink
Bank::unix_timestamp_from_genesis use saturating math (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored May 12, 2024
1 parent f868aa3 commit 246e898
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,11 @@ impl Bank {

/// computed unix_timestamp at this slot height
pub fn unix_timestamp_from_genesis(&self) -> i64 {
self.genesis_creation_time + ((self.slot as u128 * self.ns_per_slot) / 1_000_000_000) as i64
self.genesis_creation_time.saturating_add(
(self.slot as u128)
.saturating_mul(self.ns_per_slot)
.saturating_div(1_000_000_000) as i64,
)
}

fn update_sysvar_account<F>(&self, pubkey: &Pubkey, updater: F)
Expand Down

0 comments on commit 246e898

Please sign in to comment.