ouroboros-consensus:unstable-consensus-testlib
Safe HaskellNone
LanguageHaskell2010

Test.Ouroboros.Consensus.ChainGenerator.BitVector

Synopsis

Finding

data MaybeFound base Source #

Constructors

NothingFound 
JustFound !(Index base 'SlotE) 

Instances

Instances details
Eq (MaybeFound base) Source # 
Instance details

Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector

Methods

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

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

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

showsPrec ∷ Int → MaybeFound base → ShowS #

show ∷ MaybeFound base → String #

showList ∷ [MaybeFound base] → ShowS #

findIthEmptyInMV ∷ ∀ proxy (pol ∷ Pol) base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index 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

findIthEmptyInV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Index base (PreImage pol 'EmptySlotE) → MaybeFound base Source #

Trivial wrapper around findIthEmptyInMV

Counting

countActivesInMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → ST s (Var base (PreImage pol 'ActiveSlotE)) Source #

The number of active slots in the vector

countActivesInV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Size base (PreImage pol 'ActiveSlotE) Source #

Trivial wrapper around countActivesInMV

Slots

setMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base 'SlotE → ST s () Source #

testMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base 'SlotE → ST s Bool Source #

testV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Index base 'SlotE → Bool Source #

Generating

data SomeDensityWindow (pol ∷ 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

SomeDensityWindow 

Fields

fillInWindow Source #

Arguments

∷ ∀ proxy (pol ∷ 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