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

Test.Ouroboros.Consensus.ChainGenerator.RaceIterator

Description

These functions iteratively produce all race windows in a slot vector.

The first window is produced by init, which unconditionally starts the window at the first slot. This window can then be passed to next, which starts the new window after the first active slot.

---X--X--X--X-- ...
^ start of window 1 from init
    ^ start of window 2 from next
       ^ start of window 3 from next

Valid windows must have k+1 active slots. If the vector doesn't have sufficient slots to meet this condition, init and next return Nothing and we fall back to initConservative and nextConservative, which return windows truncated at the end of time.

Synopsis

Documentation

newtype Race base Source #

A window whose last slot contains the k+1st active slot in it

Constructors

UnsafeRace (SomeWindow RaceLbl base 'SlotE) 

Bundled Patterns

pattern Race ∷ SomeWindow RaceLbl base 'SlotE → Race base 

Instances

Instances details
Eq (Race base) Source # 
Instance details

Defined in Test.Ouroboros.Consensus.ChainGenerator.RaceIterator

Methods

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

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

Read (Race base) Source # 
Instance details

Defined in Test.Ouroboros.Consensus.ChainGenerator.RaceIterator

Methods

readsPrec ∷ Int → ReadS (Race base) #

readList ∷ ReadS [Race base] #

readPrec ∷ ReadPrec (Race base) #

readListPrec ∷ ReadPrec [Race base] #

Show (Race base) Source # 
Instance details

Defined in Test.Ouroboros.Consensus.ChainGenerator.RaceIterator

Methods

showsPrec ∷ Int → Race base → ShowS #

show ∷ Race base → String #

showList ∷ [Race base] → ShowS #

init ∷ Kcp → Vector base 'SlotE S → Maybe (Race base) Source #

Yields the race window starting at position 0 of the given vector if the k+1 active slot exists.

initConservative ∷ Vector base 'SlotE S → Race base Source #

initConservative creates a window for the whole vector.

next ∷ Vector base 'SlotE S → Race base → Maybe (Race base) Source #

next v r yields the race window anchored at the first active slot of r if there is an active slot after r.

nextConservative ∷ Vector base 'SlotE S → Race base → Maybe (Race base) Source #

nextConservative v r yields a window anchored at the first active slot of r if it exists, and extending until the end of v.