Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functionality for calculating
SyncProgress
of wallets.
Synopsis
-
data
SyncProgress
- = Ready
- | Syncing !( Quantity "percent" Percentage )
- | NotResponding
- newtype SyncTolerance = SyncTolerance NominalDiffTime
- mkSyncTolerance :: Int -> SyncTolerance
- syncProgress :: ( HasCallStack , Monad m) => SyncTolerance -> TimeInterpreter m -> SlotNo -> RelativeTime -> m SyncProgress
Types
data SyncProgress Source #
Ready | |
Syncing !( Quantity "percent" Percentage ) | |
NotResponding |
Instances
newtype SyncTolerance Source #
Instances
mkSyncTolerance :: Int -> SyncTolerance Source #
Construct a
SyncTolerance
from a number of
seconds
Implementations
:: ( HasCallStack , Monad m) | |
=> SyncTolerance |
A time tolerance inside which we consider ourselves synced |
-> TimeInterpreter m |
Converts slots to actual time. |
-> SlotNo |
Slot of latest block consumed |
-> RelativeTime |
Current wall clock time |
-> m SyncProgress |
Estimate restoration progress based on:
- The slot of the latest block consumed (our progress)
- The slot corresponding to the latest wall-clock time (our target)
The estimated progress is the quotient of these two quantities.
In the Cardano consensus protocol, only a fraction of slots contains blocks. Hence, the progress percentage will often be < 100%, as the slot corresponding to the current wall-clock time may not be filled with a block. The sync tolerance should be large enough to accommodate this issue.