ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Description

Snapshots

Snapshotting a ledger state means saving a copy of the state to disk, so that a later start of a cardano-node can use such a snapshot as a starting point instead of having to replay from Genesis.

A snapshot is identified by the slot number of the ledger state it contains and possibly has a suffix in the name. The consensus logic will not delete a snapshot if it has a suffix. This can be used to store important snapshots. The suffix can be manually added to the snapshot by renaming the folder (see the caveats in snapshotManager for the LSM backend). It will also be added automatically by some tools such as db-analyser.

In general snapshots will be stored in the ./ledger directory inside the ChainDB directory, but each LedgerDB backend is free to store it somewhere else. Management of snapshots is done through the SnapshotManager record (see the snapshotManager functions on each backend).

Snapshots cosists of two parts:

  • the ledger state tables: location and format differs among backends,
  • the rest of the ledger state: a CBOR serialization of an ExtLedgerState blk EmptyMK, stored in the ./state file in the snapshot directory.

V2 backends will provide means of loading a snapshot via the method newHandleFromSnapshot. V1 backends load the snapshot directly in initFromSnapshot.

Synopsis

Snapshots

data CRCError Source #

Constructors

CRCInvalid 
CRCNoFile 

Instances

Instances details
Show CRCError Source # 
Instance details

Defined in Ouroboros.Consensus.Util.CRC

Methods

showsPrecIntCRCErrorShowS #

showCRCErrorString #

showList ∷ [CRCError] → ShowS #

Eq CRCError Source # 
Instance details

Defined in Ouroboros.Consensus.Util.CRC

Methods

(==)CRCErrorCRCErrorBool #

(/=)CRCErrorCRCErrorBool #

data DiskSnapshot Source #

Name of a disk snapshot.

The snapshot itself might not yet exist on disk.

Constructors

DiskSnapshot 

Fields

  • dsNumberWord64

    Snapshots are numbered. We will try the snapshots with the highest number first.

    When creating a snapshot, we use the slot number of the ledger state it corresponds to as the snapshot number. This gives an indication of how recent the snapshot is.

    Note that the snapshot names are only indicative, we don't rely on the snapshot number matching the slot number of the corresponding ledger state. We only use the snapshots numbers to determine the order in which we try them.

  • dsSuffixMaybe String

    Snapshots can optionally have a suffix, separated by the snapshot number with an underscore, e.g., 4492799_last_Byron. This suffix acts as metadata for the operator of the node. Snapshots with a suffix will not be deleted.

Instances

Instances details
Generic DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep DiskSnapshot 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep DiskSnapshot = D1 ('MetaData "DiskSnapshot" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) (C1 ('MetaCons "DiskSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "dsNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "dsSuffix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))))
Show DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Eq DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep DiskSnapshot = D1 ('MetaData "DiskSnapshot" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) (C1 ('MetaCons "DiskSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "dsNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "dsSuffix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))))

data MetadataErr Source #

Constructors

MetadataFileDoesNotExist

The metadata file does not exist

MetadataInvalid String

The metadata file is invalid and does not deserialize

MetadataBackendMismatch

The metadata file has the incorrect backend

data ReadSnapshotErr Source #

Constructors

ReadSnapshotFailed ReadIncrementalErr

Error while de-serialising data

ReadSnapshotDataCorruption

Checksum of read snapshot differs from the one tracked by its corresponding metadata file

ReadMetadataError FsPath MetadataErr

An error occurred while reading the snapshot metadata file

ReadSnapshotIsLegacy

We were given a legacy snapshot

data SnapshotFailure blk Source #

Constructors

InitFailureRead ReadSnapshotErr

We failed to deserialise the snapshot

This can happen due to data corruption in the ledger DB or if the codecs changed.

InitFailureTooRecent DiskSnapshot (Point blk)

This snapshot is too recent (ahead of the tip of the immutable chain)

InitFailureGenesis

This snapshot was of the ledger state at genesis, even though we never take snapshots at genesis, so this is unexpected.

Instances

Instances details
Generic (SnapshotFailure blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep (SnapshotFailure blk) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (SnapshotFailure blk) = D1 ('MetaData "SnapshotFailure" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) (C1 ('MetaCons "InitFailureRead" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReadSnapshotErr)) :+: (C1 ('MetaCons "InitFailureTooRecent" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Point blk))) :+: C1 ('MetaCons "InitFailureGenesis" 'PrefixI 'False) (U1TypeType)))

Methods

fromSnapshotFailure blk → Rep (SnapshotFailure blk) x #

toRep (SnapshotFailure blk) x → SnapshotFailure blk #

StandardHash blk ⇒ Show (SnapshotFailure blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Methods

showsPrecIntSnapshotFailure blk → ShowS #

showSnapshotFailure blk → String #

showList ∷ [SnapshotFailure blk] → ShowS #

StandardHash blk ⇒ Eq (SnapshotFailure blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Methods

(==)SnapshotFailure blk → SnapshotFailure blk → Bool #

(/=)SnapshotFailure blk → SnapshotFailure blk → Bool #

type Rep (SnapshotFailure blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (SnapshotFailure blk) = D1 ('MetaData "SnapshotFailure" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) (C1 ('MetaCons "InitFailureRead" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReadSnapshotErr)) :+: (C1 ('MetaCons "InitFailureTooRecent" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Point blk))) :+: C1 ('MetaCons "InitFailureGenesis" 'PrefixI 'False) (U1TypeType)))

newtype NumOfDiskSnapshots Source #

Number of snapshots to be stored on disk. See the SnapshotPolicy documentation for more information.

Instances

Instances details
Generic NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep NumOfDiskSnapshots 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep NumOfDiskSnapshots = D1 ('MetaData "NumOfDiskSnapshots" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'True) (C1 ('MetaCons "NumOfDiskSnapshots" 'PrefixI 'True) (S1 ('MetaSel ('Just "getNumOfDiskSnapshots") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word)))
Show NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Eq NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep NumOfDiskSnapshots = D1 ('MetaData "NumOfDiskSnapshots" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'True) (C1 ('MetaCons "NumOfDiskSnapshots" 'PrefixI 'True) (S1 ('MetaSel ('Just "getNumOfDiskSnapshots") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word)))

Codec

readExtLedgerState ∷ ∀ (m ∷ TypeType) blk. IOLike m ⇒ SomeHasFS m → (∀ s. Decoder s (ExtLedgerState blk EmptyMK)) → (∀ s. Decoder s (HeaderHash blk)) → FsPathExceptT ReadIncrementalErr m (ExtLedgerState blk EmptyMK, CRC) Source #

Read an extended ledger state from disk

writeExtLedgerStateMonadThrow m ⇒ SomeHasFS m → (ExtLedgerState blk EmptyMKEncoding) → FsPathExtLedgerState blk EmptyMK → m CRC Source #

Write an extended ledger state to disk

Paths

diskSnapshotIsTemporaryDiskSnapshotBool Source #

The snapshots that are periodically created are temporary, they will be deleted when trimming or if they fail to deserialize.

snapshotToStatePathDiskSnapshotFsPath Source #

The path within the LedgerDB's filesystem to the file that contains the snapshot's serialized ledger state

snapshotToDirPathDiskSnapshotFsPath Source #

The path within the LedgerDB's filesystem to the snapshot's directory

Management

data SnapshotManager (m ∷ TypeType) (n ∷ TypeType) blk st Source #

Management of snapshots for the different LedgerDB backends.

The LedgerDB V1 takes snapshots in ReadLocked m, hence the two different m and n monad types.

defaultDeleteSnapshotIfTemporary ∷ (MonadCatch m, HasCallStack) ⇒ SomeHasFS m → Tracer m (TraceSnapshotEvent blk) → DiskSnapshot → m () Source #

Delete snapshot from disk

defaultListSnapshotsMonad m ⇒ SomeHasFS m → m [DiskSnapshot] Source #

List on-disk snapshots, highest number first.

trimSnapshots ∷ ∀ m (n ∷ TypeType) blk st. Monad m ⇒ SnapshotManager m n blk st → SnapshotPolicy → m [DiskSnapshot] Source #

Trim the number of on disk snapshots so that at most onDiskNumSnapshots snapshots are stored on disk. The oldest snapshots are deleted.

The deleted snapshots are returned.

loadSnapshotMetadata ∷ ∀ (m ∷ TypeType). IOLike m ⇒ SomeHasFS m → DiskSnapshotExceptT MetadataErr m SnapshotMetadata Source #

Load a snapshot metadata JSON file.

writeSnapshotMetadataMonadThrow m ⇒ SomeHasFS m → DiskSnapshotSnapshotMetadata → m () Source #

Write a snapshot metadata JSON file.

Policy

data SnapshotPolicy Source #

Snapshots 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

SnapshotPolicy 

Fields

  • onDiskNumSnapshotsNumOfDiskSnapshots

    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.
  • onDiskSnapshotSelectorSnapshotSelectorContext → [SlotNo]

    Select the slots to take a snapshot for, in increasing order. Must be a sublist of sscSnapshotSlots.

    See also defaultSnapshotPolicy

  • onDiskSnapshotDelayRangeSnapshotDelayRange

    Minimum and maximum durations of the random delay between requesting a snapshot and taking that snapshot.

data SnapshotDelayRange Source #

Range from which the randomised snapshot delay will be taken. The randomly chosen duration will be at least minimumDelay and at most maximumDelay.

Constructors

SnapshotDelayRange 

Fields

  • minimumDelay ∷ !DiffTime

    minimum acceptable delay between requesting a snapshot and taking the snapshot

  • maximumDelay ∷ !DiffTime

    maximum acceptable delay between requesting a snapshot and taking the snapshot

Instances

Instances details
Generic SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep SnapshotDelayRange 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep SnapshotDelayRange = D1 ('MetaData "SnapshotDelayRange" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) (C1 ('MetaCons "SnapshotDelayRange" 'PrefixI 'True) (S1 ('MetaSel ('Just "minimumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime) :*: S1 ('MetaSel ('Just "maximumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime)))
Show SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Eq SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

NoThunks SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep SnapshotDelayRange = D1 ('MetaData "SnapshotDelayRange" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) (C1 ('MetaCons "SnapshotDelayRange" 'PrefixI 'True) (S1 ('MetaSel ('Just "minimumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime) :*: S1 ('MetaSel ('Just "maximumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime)))

data SnapshotSelectorContext Source #

Constructors

SnapshotSelectorContext 

Fields

  • sscTimeSinceLastMaybe DiffTime

    The time since the last snapshot, or Nothing if none was taken yet. Note that Nothing merely means no snapshot had been taking yet since the node was started; it does not necessarily mean that none exist on disk.

  • sscSnapshotSlots ∷ [SlotNo]

    An increasing list of slots for which a snapshot can be taken (as the corresponding ledger state is immutable). The result of onDiskSnapshotSelector must be a subset of this list.

data SnapshotFrequencyArgs Source #

Determines when/how often we take ledger snapshots.

We only write snapshots for ledger states that are immutable. Concretely, for every slot s out of

sfaOffset, sfaOffset + sfaInterval, sfaOffset + 2 * sfaInterval, sfaOffset + 3 * sfaInterval, ...

we write a snapshot for the most recent immutable ledger state before s. This way, nodes with the same sfaInterval/sfaOffset configuration create snapshots for precisely the same slots.

For example, on Cardano mainnet, where k=2160 and f=1/20, setting sfaInterval = 10*k/f = 432000 (one epoch) and sfaOffset = 0 will cause the node to create snapshots for the last block in every Shelley epoch. By setting sfaOffset to eg 5*k/f (half an epoch), snapshots are created just before the midway point in each epoch.

Additionally, there is an (optional, opt-out) rate limit (useful while bulk-syncing). When set to a given duration, we will skip writing a snapshot if less time than the given duration has passed since we finished writing the previous snapshot (if any).

To avoid skipping a snapshot write when caught-up, it is advisable to set sfaRateLimit to something significantly smaller than the wall-clock duration of sfaInterval.

Constructors

SnapshotFrequencyArgs 

Fields

defaultSnapshotPolicySecurityParamSnapshotPolicyArgsSnapshotPolicy Source #

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

mithrilEpochSizeWord64 Source #

The Cardano mainnet epoch length in slots, used as the reference for the Mithril snapshot compatibility check in sanityCheckSnapshotPolicyArgs. Mithril requires a ledger snapshot at each epoch boundary; for snapshots to land on every epoch boundary, sfaInterval must divide this value evenly.

sanityCheckSnapshotPolicyArgsSnapshotPolicyArgs → [SanityCheckIssue] Source #

Check a SnapshotPolicyArgs for suspicious configurations and return a (possibly empty) list of SanityCheckIssues describing any problems found.

Only Override values are checked — UseDefault values are known-good and are never flagged. Checks that are specific to SnapshotFrequency are skipped entirely when spaFrequency is DisableSnapshots.

pattern DoDiskSnapshotChecksumFlag "DoDiskSnapshotChecksum" Source #

Type-safe flag to regulate the checksum policy of the ledger state snapshots.

These patterns are exposed to cardano-node and will be passed as part of SnapshotPolicy.

pattern NoDoDiskSnapshotChecksumFlag "DoDiskSnapshotChecksum" Source #

Type-safe flag to regulate the checksum policy of the ledger state snapshots.

These patterns are exposed to cardano-node and will be passed as part of SnapshotPolicy.

Tracing

data TraceSnapshotEvent blk Source #

Constructors

InvalidSnapshot DiskSnapshot (SnapshotFailure blk)

An on disk snapshot was skipped because it was invalid.

SnapshotRequestDelayed Time DiffTime (NonEmpty SlotNo)

A delayed snapshot requested was issued at a timestamp, with a delay and for ledger states at the specified slot numbers

SnapshotRequestCompleted

A snapshot request was completed

TookSnapshot DiskSnapshot (RealPoint blk) EnclosingTimed

A snapshot was written to disk.

DeletedSnapshot DiskSnapshot

An old or invalid on-disk snapshot was deleted

Instances

Instances details
Generic (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep (TraceSnapshotEvent blk) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (TraceSnapshotEvent blk) = D1 ('MetaData "TraceSnapshotEvent" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) ((C1 ('MetaCons "InvalidSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SnapshotFailure blk))) :+: C1 ('MetaCons "SnapshotRequestDelayed" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Time) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiffTime) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty SlotNo))))) :+: (C1 ('MetaCons "SnapshotRequestCompleted" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "TookSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (RealPoint blk)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EnclosingTimed))) :+: C1 ('MetaCons "DeletedSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot)))))
StandardHash blk ⇒ Show (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

StandardHash blk ⇒ Eq (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (TraceSnapshotEvent blk) = D1 ('MetaData "TraceSnapshotEvent" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-3.0.1.0-inplace" 'False) ((C1 ('MetaCons "InvalidSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SnapshotFailure blk))) :+: C1 ('MetaCons "SnapshotRequestDelayed" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Time) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiffTime) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty SlotNo))))) :+: (C1 ('MetaCons "SnapshotRequestCompleted" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "TookSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (RealPoint blk)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EnclosingTimed))) :+: C1 ('MetaCons "DeletedSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot)))))

Re-exports

newtype Flag (name ∷ Symbol) Source #

Type-safe boolean flags with type level tags

It is recommended to create pattern synonyms for the true and false values.

See DiskSnapshotChecksum for an example.

Constructors

Flag 

Fields

Instances

Instances details
Generic (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

Associated Types

type Rep (Flag name) 
Instance details

Defined in Ouroboros.Consensus.Util

type Rep (Flag name) = D1 ('MetaData "Flag" "Ouroboros.Consensus.Util" "ouroboros-consensus-3.0.1.0-inplace" 'True) (C1 ('MetaCons "Flag" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFlag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

Methods

fromFlag name → Rep (Flag name) x #

toRep (Flag name) x → Flag name #

Show (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

Methods

showsPrecIntFlag name → ShowS #

showFlag name → String #

showList ∷ [Flag name] → ShowS #

Eq (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

Methods

(==)Flag name → Flag name → Bool #

(/=)Flag name → Flag name → Bool #

type Rep (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

type Rep (Flag name) = D1 ('MetaData "Flag" "Ouroboros.Consensus.Util" "ouroboros-consensus-3.0.1.0-inplace" 'True) (C1 ('MetaCons "Flag" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFlag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

Testing

decodeLBackwardsCompatible ∷ ∀ l blk. Proxy blk → (∀ s. Decoder s l) → (∀ s. Decoder s (HeaderHash blk)) → ∀ s. Decoder s l Source #

To remain backwards compatible with existing snapshots stored on disk, we must accept the old format as well as the new format.

The old format:

  • The tip: WithOrigin (RealPoint blk)
  • The chain length: Word64
  • The ledger state: l

The new format is described by snapshotEncodingVersion1.

This decoder will accept and ignore them. The encoder (encodeSnapshot) will no longer encode them.

destroySnapshots ∷ ∀ m (n ∷ TypeType) blk st. Monad m ⇒ SnapshotManager m n blk st → m () Source #

Testing only! Destroy all snapshots in the DB.

encodeL ∷ (l → Encoding) → l → Encoding Source #

Encoder to be used in combination with decodeSnapshotBackwardsCompatible.

snapshotsMapM_ ∷ ∀ m (n ∷ TypeType) blk st a. Monad m ⇒ SnapshotManager m n blk st → (DiskSnapshot → m a) → m () Source #