Skip to content

Commit

Permalink
Difficulty RFC: Add a median_timespan function
Browse files Browse the repository at this point in the history
And fix the median_timespan_bounded comment
  • Loading branch information
teor2345 authored Nov 19, 2020
1 parent 8dcfdbf commit bd1f330
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions book/src/dev/rfcs/0006-contextual-difficulty.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,10 @@ than any "actual" elapsed time.)
Zebra implements the median timespan using the following methods on
`AdjustedDifficulty`:
```rust
/// Calculate the median timespan. The median timespan is the difference of
/// medians of the timespan times, which are the `time`s from the previous
/// `PoWAveragingWindow + PoWMedianBlockSpan` (28) blocks in the relevant chain.
/// Calculate the bounded median timespan. The median timespan is the
/// difference of medians of the timespan times, which are the `time`s from
/// the previous `PoWAveragingWindow + PoWMedianBlockSpan` (28) blocks in the
/// relevant chain.
///
/// Uses the candidate block's `height' and `network` to calculate the
/// `AveragingWindowTimespan` for that block.
Expand All @@ -458,6 +459,15 @@ Zebra implements the median timespan using the following methods on
/// start and end of the timespan times. timespan times `[11..=16]` are ignored.
fn median_timespan_bounded(&self) -> Duration { ... }

/// Calculate the median timespan. The median timespan is the difference of
/// medians of the timespan times, which are the `time`s from the previous
/// `PoWAveragingWindow + PoWMedianBlockSpan` (28) blocks in the relevant chain.
///
/// Implements `ActualTimespan` from the Zcash specification.
///
/// See `median_timespan_bounded` for details.
fn median_timespan(&self) -> Duration { ... }

/// Calculate the median of the `median_block_span_times`: the `time`s from a
/// slice of `PoWMedianBlockSpan` (11) blocks in the relevant chain.
///
Expand Down

0 comments on commit bd1f330

Please sign in to comment.