From bd1f330d1a6812f58f34b17019dec40d48c071ba Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 19 Nov 2020 12:03:20 +1000 Subject: [PATCH] Difficulty RFC: Add a median_timespan function And fix the median_timespan_bounded comment --- book/src/dev/rfcs/0006-contextual-difficulty.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/book/src/dev/rfcs/0006-contextual-difficulty.md b/book/src/dev/rfcs/0006-contextual-difficulty.md index 8dfe37b3a4e..091ddf50d19 100644 --- a/book/src/dev/rfcs/0006-contextual-difficulty.md +++ b/book/src/dev/rfcs/0006-contextual-difficulty.md @@ -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. @@ -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. ///