HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulecardano-protocol-0.1.0.0Haskell2010

Cardano.Protocol.TPraos.BlockHeader

  • 7 types
  • 17 values
newtypenewtype HashHeader
#
Instances9Eq, Ord, Show, Generic, NFData, NoThunks, …
datadata PrevHash
#

The previous hash of a block

Instances8Eq, Ord, Show, Generic, NoThunks, DecCBOR, …
newtypenewtype BHeader c
#
Instances13Eq, Show, Generic, NoThunks, ToCBOR, DecCBOR, …
datadata BHeaderRaw c
#
Instances9Eq, Show, Generic, NoThunks, DecCBOR, EncCBOR, …
datadata BHBody c
#

Constructors

Instances8Eq, Show, Generic, NoThunks, SignableRepresentation, DecCBOR, …
datadata LastAppliedBlock
#
Instances8Eq, Show, Generic, NFData, NoThunks, DecCBOR, …
datadata BoundedNatural
#

Natural value with some additional bound. It must always be the base that 'bvValue <= bvMaxValue'. The creator is responsible for checking this value.

valuecheckLeaderNatValue
  1. :: BoundedNatural

    Certified nat value

  2. -> Rational

    Stake proportion

  3. -> ActiveSlotCoeff
  4. -> Bool
#

Check that the certified input natural is valid for being slot leader. This means we check that

p < 1 - (1 - f)^σ

where p = certNat / certNatMax.

The calculation is done using the following optimization:

let q = 1 - p and c = ln(1 - f)

then p < 1 - (1 - f)^σ = 1 / (1 - p) < exp(-σ * c) = 1 / q < exp(-σ * c)

This can be efficiently be computed by taylorExpCmp which returns ABOVE in case the reference value `1 / (1 - p)` is above the exponential function at `-σ * c`, BELOW if it is below or MaxReached if it couldn't conclusively compute this within the given iteration bounds.

Note that 1 1 1 certNatMax --- = ----- = ---------------------------- = ---------------------- q 1 - p 1 - (certNat / certNatMax) (certNatMax - certNat)