ouroboros-consensus-0.18.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Ouroboros.Consensus.ChainGenerator.BitVector

Synopsis

Finding

data MaybeFound base Source #

Constructors

NothingFound 
JustFound !(Index base SlotE) 

Instances

Instances details
Read (MaybeFound base) Source # 
Instance details

Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector

Show (MaybeFound base) Source # 
Instance details

Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector

Methods

showsPrecIntMaybeFound base → ShowS #

showMaybeFound base → String #

showList ∷ [MaybeFound base] → ShowS #

Eq (MaybeFound base) Source # 
Instance details

Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector

Methods

(==)MaybeFound base → MaybeFound base → Bool #

(/=)MaybeFound base → MaybeFound base → Bool #

findIthEmptyInMV ∷ ∀ proxy pol base s. POL pol ⇒ proxy pol → MVector base SlotE s SIndex base (PreImage pol EmptySlotE) → ST s (MaybeFound base) Source #

Find the (i+1)st empty slot in a window

  • findIthEmptyInMV notInverted v 0 yields the first empty slot
  • findIthEmptyInMV notInverted v 1 yields the second empty slot
  • findIthEmptyInMV notInverted v k yields the k+1st empty slot
findIthEmptyInMV notInverted 01101 0 == JustFound 0
findIthEmptyInMV notInverted 01101 1 == JustFound 3
findIthEmptyInMV notInverted 01101 2 == NothingFound

findIthEmptyInVPOL pol ⇒ proxy pol → Vector base SlotE SIndex base (PreImage pol EmptySlotE) → MaybeFound base Source #

Trivial wrapper around findIthEmptyInMV

Counting

countActivesInMVPOL pol ⇒ proxy pol → MVector base SlotE s SST s (Var base (PreImage pol ActiveSlotE)) Source #

The number of active slots in the vector

countActivesInVPOL pol ⇒ proxy pol → Vector base SlotE SSize base (PreImage pol ActiveSlotE) Source #

Trivial wrapper around countActivesInMV

Slots

setMVPOL pol ⇒ proxy pol → MVector base SlotE s SIndex base SlotEST s () Source #

testMVPOL pol ⇒ proxy pol → MVector base SlotE s SIndex base SlotEST s Bool Source #

testVPOL pol ⇒ proxy pol → Vector base SlotE SIndex base SlotEBool Source #

Generating

data SomeDensityWindow pol Source #

A density of active slots in a given window

pol is the polarity to use for the active slots

TODO: rename to SomeDensity

Constructors

∀ slidingWindow. SomeDensityWindow 

Fields

fillInWindow Source #

Arguments

∷ ∀ proxy pol base g s. (POL pol, StatefulGen g (ST s)) 
⇒ proxy pol 
SomeDensityWindow pol 
→ g 
MVector base SlotE s S 
ST s (Var base (PreImage pol ActiveSlotE))

the count after filling

fillInWindow pol (SomeDensityWindow k s) g mv mutates mv to ensure that the vector take s $ mv ++ repeat (mkActive pol) has at least k slots polarizely active.

Preconditions:

lengthMV mv <= s
k <= s