Skip to content

Commit

Permalink
Merge branch 'jason/cleanup-rename-variables' into 'master'
Browse files Browse the repository at this point in the history
Rename timestamp/duration related variables

Addressing a comment from previous MR: !13469 

See merge request dfinity-lab/public/ic!13487
  • Loading branch information
max-dfinity committed Jul 12, 2023
2 parents e1907c9 + 342e2fe commit 2fbc7ec
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rs/nns/governance/src/neuron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::collections::HashMap;
const ONE_DAY_SECONDS: u64 = 24 * 60 * 60;
const ONE_YEAR_SECONDS: u64 = (4 * 365 + 1) * ONE_DAY_SECONDS / 4;
const ONE_MONTH_SECONDS: u64 = ONE_YEAR_SECONDS / 12;
const GTC_NEURON_PRE_AGE_SECONDS: u64 = 18 * ONE_MONTH_SECONDS;
const GTC_NEURON_PRE_AGE_DURATION_SECONDS: u64 = 18 * ONE_MONTH_SECONDS;

impl Neuron {
// --- Utility methods on neurons: mostly not for public consumption.
Expand Down Expand Up @@ -615,11 +615,12 @@ impl Neuron {

/// If the aging timestamp is earlier than GENESIS - PRE_AGE, reset it to GENISIS.
pub fn maybe_reset_aging_timestamp(&mut self) -> bool {
let genesis_seconds = ic_types::time::GENESIS.as_secs_since_unix_epoch();
let aging_limit = genesis_seconds.saturating_sub(GTC_NEURON_PRE_AGE_SECONDS);
let should_reset = self.aging_since_timestamp_seconds < aging_limit;
let genesis_timestamp_seconds = ic_types::time::GENESIS.as_secs_since_unix_epoch();
let aging_limit_timestamp_seconds =
genesis_timestamp_seconds.saturating_sub(GTC_NEURON_PRE_AGE_DURATION_SECONDS);
let should_reset = self.aging_since_timestamp_seconds < aging_limit_timestamp_seconds;
if should_reset {
self.aging_since_timestamp_seconds = genesis_seconds;
self.aging_since_timestamp_seconds = genesis_timestamp_seconds;
}
should_reset
}
Expand Down

0 comments on commit 2fbc7ec

Please sign in to comment.