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

Ouroboros.Consensus.BlockchainTime.WallClock.Simple

Synopsis

Documentation

simpleBlockchainTime Source #

Arguments

∷ ∀ m. IOLike m 
ResourceRegistry m 
SystemTime m 
SlotLength 
NominalDiffTime

Max clock rewind

→ m (BlockchainTime m) 

Real blockchain time

WARNING: if the start time is in the future, simpleBlockchainTime will block until the start time has come.

Low-level API (exported primarily for testing)

getWallClockSlotIOLike m ⇒ SystemTime m → SlotLength → m (SlotNo, NominalDiffTime) Source #

Get current slot and time spent in that slot

waitUntilNextSlot Source #

Arguments

IOLike m 
SystemTime m 
SlotLength 
NominalDiffTime

Max clock rewind

SlotNo

Current slot number

→ m SlotNo 

Wait until the next slot

Takes the current slot number to guard against system clock changes. If the clock changes back further than the max clock rewind parameter, a fatal SystemClockMovedBack exception will be thrown. When this exception is thrown, the node will shut down, and should be restarted with (full?) validation enabled: it is conceivable that blocks got moved to the immutable DB that, due to the clock change, should not be considered immutable anymore.

If the clock changed back less than the max clock rewind parameter, we stay in the same slot for longer and don't throw an exception.