mirror of https://github.com/zcash/zips.git
Add type declarations for height in difficulty adjustment functions.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
65d43bfac4
commit
ea346eaca8
|
@ -9009,28 +9009,28 @@ Define:
|
||||||
-\floor{-x},&\caseotherwise
|
-\floor{-x},&\caseotherwise
|
||||||
\end{cases}$
|
\end{cases}$
|
||||||
\blossom{
|
\blossom{
|
||||||
\item $\IsBlossomActivated(\BlockHeight) := (\BlockHeight \geq \BlossomActivationHeight)$
|
\item $\IsBlossomActivated(\BlockHeight \typecolon \Nat) := (\BlockHeight \geq \BlossomActivationHeight)$
|
||||||
\item $\BlossomPoWTargetSpacingRatio := \hfrac{\PreBlossomPoWTargetSpacing}{\PostBlossomPoWTargetSpacing}$
|
\item $\BlossomPoWTargetSpacingRatio := \hfrac{\PreBlossomPoWTargetSpacing}{\PostBlossomPoWTargetSpacing}$
|
||||||
\item $\PostBlossomHalvingInterval := \floor{\PreBlossomHalvingInterval \mult \BlossomPoWTargetSpacingRatio}$
|
\item $\PostBlossomHalvingInterval := \floor{\PreBlossomHalvingInterval \mult \BlossomPoWTargetSpacingRatio}$
|
||||||
\item $\PoWTargetSpacingFunc(\BlockHeight) := \begin{cases}
|
\item $\PoWTargetSpacingFunc(\BlockHeight \typecolon \Nat) := \begin{cases}
|
||||||
\PreBlossomPoWTargetSpacing,&\caseif \text{not } \IsBlossomActivated(\BlockHeight) \\
|
\PreBlossomPoWTargetSpacing,&\caseif \text{not } \IsBlossomActivated(\BlockHeight) \\
|
||||||
\PostBlossomPoWTargetSpacing,&\caseotherwise
|
\PostBlossomPoWTargetSpacing,&\caseotherwise
|
||||||
\end{cases}$
|
\end{cases}$
|
||||||
} %blossom
|
} %blossom
|
||||||
|
|
||||||
\item $\AveragingWindowTimespan\blossom{(\BlockHeight)} := \PoWAveragingWindow \mult \PoWTargetSpacingFunc\blossom{(\BlockHeight)}$
|
\item $\AveragingWindowTimespan\blossom{(\BlockHeight \typecolon \Nat)} := \PoWAveragingWindow \mult \PoWTargetSpacingFunc\blossom{(\BlockHeight)}$
|
||||||
\item $\MinActualTimespan\blossom{(\BlockHeight)} := \floor{\AveragingWindowTimespan\blossom{(\BlockHeight)} \mult (1 - \PoWMaxAdjustUp)}$
|
\item $\MinActualTimespan\blossom{(\BlockHeight \typecolon \Nat)} := \floor{\AveragingWindowTimespan\blossom{(\BlockHeight)} \mult (1 - \PoWMaxAdjustUp)}$
|
||||||
\item $\MaxActualTimespan\blossom{(\BlockHeight)} := \floor{\AveragingWindowTimespan\blossom{(\BlockHeight)} \mult (1 + \PoWMaxAdjustDown)}$
|
\item $\MaxActualTimespan\blossom{(\BlockHeight \typecolon \Nat)} := \floor{\AveragingWindowTimespan\blossom{(\BlockHeight)} \mult (1 + \PoWMaxAdjustDown)}$
|
||||||
\item $\MedianTime(\BlockHeight) := \median(\listcomp{\nTime(i) \for i \from
|
\item $\MedianTime(\BlockHeight \typecolon \Nat) :=
|
||||||
\maximum(0, \BlockHeight - \PoWMedianBlockSpan) \upto \BlockHeight - 1})$
|
\median(\listcomp{\nTime(i) \for i \from \maximum(0, \BlockHeight - \PoWMedianBlockSpan) \upto \BlockHeight - 1})$
|
||||||
\item $\ActualTimespan(\BlockHeight) := \MedianTime(\BlockHeight) - \MedianTime(\BlockHeight - \PoWAveragingWindow)$
|
\item $\ActualTimespan(\BlockHeight \typecolon \Nat) := \MedianTime(\BlockHeight) - \MedianTime(\BlockHeight - \PoWAveragingWindow)$
|
||||||
\item $\ActualTimespanDamped(\BlockHeight) :=$
|
\item $\ActualTimespanDamped(\BlockHeight \typecolon \Nat) :=$
|
||||||
\vspace{-0.5ex}
|
\vspace{-0.5ex}
|
||||||
\item \tab $\AveragingWindowTimespan\blossom{(\BlockHeight)} + \trunc{\scalebox{0.98}{\hfrac{\ActualTimespan(\BlockHeight) - \AveragingWindowTimespan\blossom{(\BlockHeight)}}{\PoWDampingFactor}}}$
|
\item \tab $\AveragingWindowTimespan\blossom{(\BlockHeight \typecolon \Nat)} + \trunc{\scalebox{0.98}{\hfrac{\ActualTimespan(\BlockHeight) - \AveragingWindowTimespan\blossom{(\BlockHeight)}}{\PoWDampingFactor}}}$
|
||||||
\item $\ActualTimespanBounded(\BlockHeight) := \bound{\MinActualTimespan\blossom{(\BlockHeight)}}{\MaxActualTimespan\blossom{(\BlockHeight)}}(\ActualTimespanDamped(\BlockHeight))$
|
\item $\ActualTimespanBounded(\BlockHeight \typecolon \Nat) := \bound{\MinActualTimespan\blossom{(\BlockHeight)}}{\MaxActualTimespan\blossom{(\BlockHeight)}}(\ActualTimespanDamped(\BlockHeight))$
|
||||||
\item $\MeanTarget(\BlockHeight) := \begin{cases}
|
\item $\MeanTarget(\BlockHeight \typecolon \Nat) := \begin{cases}
|
||||||
\PoWLimit, \hspace{16em}\text{if } \BlockHeight \leq \PoWAveragingWindow \\
|
\PoWLimit, \hspace{16em}\text{if } \BlockHeight \leq \PoWAveragingWindow \\
|
||||||
\mean(\listcomp{\ToTarget(\nBits(i)) \for i \from \BlockHeight - \PoWAveragingWindow \upto \BlockHeight - 1}),\\
|
\mean(\listcomp{\!\ToTarget(\nBits(i)) \for i \from \BlockHeight\!-\!\PoWAveragingWindow \upto \BlockHeight\!-\!1\!}),\\
|
||||||
\hspace{20.7em}\text{otherwise.}
|
\hspace{20.7em}\text{otherwise.}
|
||||||
\end{cases}$
|
\end{cases}$
|
||||||
\end{formulae}
|
\end{formulae}
|
||||||
|
@ -9039,13 +9039,13 @@ Define:
|
||||||
The \targetThreshold for a given \blockHeight $\BlockHeight$ is then calculated as:
|
The \targetThreshold for a given \blockHeight $\BlockHeight$ is then calculated as:
|
||||||
|
|
||||||
\begin{formulae}
|
\begin{formulae}
|
||||||
\item $\Threshold(\BlockHeight) \hspace{0.43em} := \hspace{0.43em} \begin{cases}
|
\item $\Threshold(\BlockHeight \typecolon \Nat) \hspace{0.43em} := \begin{cases}
|
||||||
\PoWLimit, \hspace{16em}\text{if } \BlockHeight = 0 \\
|
\PoWLimit, \hspace{16em}\text{if } \BlockHeight = 0 \\
|
||||||
\minimum(\PoWLimit, \floor{\hfrac{\MeanTarget(\BlockHeight)}{\AveragingWindowTimespan}}
|
\minimum(\PoWLimit, \floor{\hfrac{\MeanTarget(\BlockHeight)}{\AveragingWindowTimespan}}
|
||||||
\mult \ActualTimespanBounded(\BlockHeight)),\\
|
\mult \ActualTimespanBounded(\BlockHeight)),\\
|
||||||
\hspace{20.7em}\text{otherwise}
|
\hspace{20.7em}\text{otherwise}
|
||||||
\end{cases}$
|
\end{cases}$
|
||||||
\item $\ThresholdBits(\BlockHeight) := \ToCompact(\Threshold(\BlockHeight))$.
|
\item $\ThresholdBits(\BlockHeight \typecolon \Nat) := \ToCompact(\Threshold(\BlockHeight))$.
|
||||||
\end{formulae}
|
\end{formulae}
|
||||||
|
|
||||||
\vspace{-2ex}
|
\vspace{-2ex}
|
||||||
|
|
Loading…
Reference in New Issue