Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed May 3, 2024
1 parent cd042e3 commit 783cf8c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions zebra-state/src/service/check/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,23 +296,23 @@ impl AdjustedDifficulty {
let newer_median = self.median_time_past();

// MedianTime(height : N) := median([ nTime(𝑖) for 𝑖 from max(0, height − PoWMedianBlockSpan) up to max(0, height − 1) ])
let older_times: Vec<_> = if self.relevant_times.len() > POW_AVERAGING_WINDOW {
self.relevant_times
let older_median = if self.relevant_times.len() > POW_AVERAGING_WINDOW {
let older_times: Vec<_> = self
.relevant_times
.iter()
.skip(POW_AVERAGING_WINDOW)
.cloned()
.take(POW_MEDIAN_BLOCK_SPAN)
.collect()
.collect();

AdjustedDifficulty::median_time(older_times)
} else {
vec![self
.relevant_times
self.relevant_times
.last()
.cloned()
.expect("there must be a Genesis block")]
.expect("there must be a Genesis block")
};

let older_median = AdjustedDifficulty::median_time(older_times);

// `ActualTimespan` in the Zcash specification
newer_median - older_median
}
Expand Down

0 comments on commit 783cf8c

Please sign in to comment.