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

Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

Synopsis

Documentation

data DiskPolicy Source #

On-disk policy

We only write ledger states that are older than k blocks to disk (that is, snapshots that are guaranteed valid). The on-disk policy determines how often we write to disk and how many checkpoints we keep.

Constructors

DiskPolicy 

Fields

  • onDiskNumSnapshotsWord

    How many snapshots do we want to keep on disk?

    A higher number of on-disk snapshots is primarily a safe-guard against disk corruption: it trades disk space for reliability.

    Examples:

    • 0: Delete the snapshot immediately after writing. Probably not a useful value :-D
    • 1: Delete the previous snapshot immediately after writing the next Dangerous policy: if for some reason the deletion happens before the new snapshot is written entirely to disk (we don't fsync), we have no choice but to start at the genesis snapshot on the next startup.
    • 2: Always keep 2 snapshots around. This means that when we write the next snapshot, we delete the oldest one, leaving the middle one available in case of truncation of the write. This is probably a sane value in most circumstances.
  • onDiskShouldTakeSnapshotTimeSinceLast DiffTimeWord64Bool

    Should we write a snapshot of the ledger state to disk?

    This function is passed two bits of information:

    • The time since the last snapshot, or NoSnapshotTakenYet if none was taken yet. Note that NoSnapshotTakenYet merely means no snapshot had been taking yet since the node was started; it does not necessarily mean that none exist on disk.
    • The distance in terms of blocks applied to the oldest ledger snapshot in memory. During normal operation, this is the number of blocks written to the ImmutableDB since the last snapshot. On startup, it is computed by counting how many immutable blocks we had to reapply to get to the chain tip. This is useful, as it allows the policy to decide to take a snapshot on node startup if a lot of blocks had to be replayed.

    See also mkDiskPolicy

data NumOfDiskSnapshots Source #

Number of snapshots to be stored on disk. This is either the default value as determined by the DiskPolicy, or it is provided by the user. See the DiskPolicy documentation for more information.

Instances

Instances details
Generic NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

Associated Types

type Rep NumOfDiskSnapshotsTypeType #

Show NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

Eq NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

type Rep NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

type Rep NumOfDiskSnapshots = D1 ('MetaData "NumOfDiskSnapshots" "Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy" "ouroboros-consensus-0.18.0.0-inplace" 'False) (C1 ('MetaCons "DefaultNumOfDiskSnapshots" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "RequestedNumOfDiskSnapshots" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word)))

data SnapshotInterval Source #

Length of time, requested by the user, that has to pass after which a snapshot is taken. It can be:

  1. either explicitly provided by user in seconds
  2. or default value can be requested - the specific DiskPolicy determines what that is exactly, see mkDiskPolicy as an example

Instances

Instances details
Generic SnapshotInterval Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

Associated Types

type Rep SnapshotIntervalTypeType #

Show SnapshotInterval Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

Eq SnapshotInterval Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

type Rep SnapshotInterval Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

type Rep SnapshotInterval = D1 ('MetaData "SnapshotInterval" "Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy" "ouroboros-consensus-0.18.0.0-inplace" 'False) (C1 ('MetaCons "DefaultSnapshotInterval" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "RequestedSnapshotInterval" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiffTime)))

data TimeSinceLast time Source #

Constructors

NoSnapshotTakenYet 
TimeSinceLast time 

Instances

Instances details
Functor TimeSinceLast Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

Methods

fmap ∷ (a → b) → TimeSinceLast a → TimeSinceLast b #

(<$) ∷ a → TimeSinceLast b → TimeSinceLast a #

Show time ⇒ Show (TimeSinceLast time) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy

Methods

showsPrecIntTimeSinceLast time → ShowS #

showTimeSinceLast time → String #

showList ∷ [TimeSinceLast time] → ShowS #

defaultDiskPolicyArgsDiskPolicyArgs Source #

Default on-disk policy arguments suitable to use with cardano-node