ouroboros-consensus-0.26.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Description

The BackingStore is the component of the LedgerDB V1 implementation that stores a key-value map with the LedgerTables at a specific slot on the chain.

It is used for storing LedgerState data structures, and updating them with Diffs produced by executing the Ledger rules.

See Ouroboros.Consensus.Storage.LedgerDB.BackingStore for the implementations provided.

Synopsis

FileSystem newtypes

newtype LiveLMDBFS (m โˆท Type โ†’ Type) Source #

The LMDB file system. Typically pointing to db-path/vol-db-path/lmdb.

Constructors

LiveLMDBFS 

Fields

Instances

Instances details
Generic (LiveLMDBFS m) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Associated Types

type Rep (LiveLMDBFS m) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

type Rep (LiveLMDBFS m) = D1 ('MetaData "LiveLMDBFS" "Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "LiveLMDBFS" 'PrefixI 'True) (S1 ('MetaSel ('Just "liveLMDBFs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SomeHasFS m))))

Methods

from โˆท LiveLMDBFS m โ†’ Rep (LiveLMDBFS m) x #

to โˆท Rep (LiveLMDBFS m) x โ†’ LiveLMDBFS m #

NoThunks (LiveLMDBFS m) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

noThunks โˆท Context โ†’ LiveLMDBFS m โ†’ IO (Maybe ThunkInfo) Source #

wNoThunks โˆท Context โ†’ LiveLMDBFS m โ†’ IO (Maybe ThunkInfo) Source #

showTypeOf โˆท Proxy (LiveLMDBFS m) โ†’ String Source #

type Rep (LiveLMDBFS m) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

type Rep (LiveLMDBFS m) = D1 ('MetaData "LiveLMDBFS" "Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "LiveLMDBFS" 'PrefixI 'True) (S1 ('MetaSel ('Just "liveLMDBFs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SomeHasFS m))))

newtype SnapshotsFS (m โˆท Type โ†’ Type) Source #

The LedgerDB file system. Typically pointing to db-path/vol-db-path/ledger.

Constructors

SnapshotsFS 

Fields

Instances

Instances details
Generic (SnapshotsFS m) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Associated Types

type Rep (SnapshotsFS m) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

type Rep (SnapshotsFS m) = D1 ('MetaData "SnapshotsFS" "Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "SnapshotsFS" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshotsFs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SomeHasFS m))))

Methods

from โˆท SnapshotsFS m โ†’ Rep (SnapshotsFS m) x #

to โˆท Rep (SnapshotsFS m) x โ†’ SnapshotsFS m #

NoThunks (SnapshotsFS m) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

noThunks โˆท Context โ†’ SnapshotsFS m โ†’ IO (Maybe ThunkInfo) Source #

wNoThunks โˆท Context โ†’ SnapshotsFS m โ†’ IO (Maybe ThunkInfo) Source #

showTypeOf โˆท Proxy (SnapshotsFS m) โ†’ String Source #

type Rep (SnapshotsFS m) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

type Rep (SnapshotsFS m) = D1 ('MetaData "SnapshotsFS" "Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "SnapshotsFS" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshotsFs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SomeHasFS m))))

Backing store

data BackingStore (m โˆท Type โ†’ Type) keys values diff Source #

Constructors

BackingStore 

Fields

  • bsClose โˆท !(m ())

    Close the backing store

    Other methods throw exceptions if called on a closed store. bsClose itself is idempotent.

  • bsCopy โˆท !(SerializeTablesHint values โ†’ FsPath โ†’ m ())

    Create a persistent copy

    Each backing store implementation will offer a way to initialize itself from such a path.

    The destination path must not already exist. After this operation, it will be a directory.

  • bsValueHandle โˆท !(m (BackingStoreValueHandle m keys values))

    Open a BackingStoreValueHandle capturing the current value of the entire database

  • bsWrite โˆท !(SlotNo โ†’ WriteHint diff โ†’ diff โ†’ m ())

    Apply a valid diff to the contents of the backing store

  • bsSnapshotBackend โˆท !SnapshotBackend

    The name of the BackingStore backend, for loading and writing snapshots to disk

Instances

Instances details
NoThunks (BackingStore m keys values diff) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

noThunks โˆท Context โ†’ BackingStore m keys values diff โ†’ IO (Maybe ThunkInfo) Source #

wNoThunks โˆท Context โ†’ BackingStore m keys values diff โ†’ IO (Maybe ThunkInfo) Source #

showTypeOf โˆท Proxy (BackingStore m keys values diff) โ†’ String Source #

type BackingStore' (m โˆท Type โ†’ Type) blk = LedgerBackingStore m (ExtLedgerState blk) Source #

data DiffsToFlush (l โˆท LedgerStateKind) Source #

A container for differences that are inteded to be flushed to a BackingStore

Constructors

DiffsToFlush 

Fields

data InitFrom values Source #

Choose how to initialize the backing store

Constructors

InitFromValues !(WithOrigin SlotNo) !(InitHint values) !values

Initialize from a set of values, at the given slot.

InitFromCopy !(InitHint values) !FsPath

Use a snapshot at the given path to overwrite the set of values in the opened database.

type family InitHint values Source #

Instances

Instances details
type InitHint (LedgerTables l ValuesMK) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

type family ReadHint values Source #

Instances

Instances details
type ReadHint (LedgerTables l ValuesMK) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

type family WriteHint diffs Source #

Instances

Instances details
type WriteHint (LedgerTables l DiffMK) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Value handle

data BackingStoreValueHandle (m โˆท Type โ†’ Type) keys values Source #

An ephemeral handle to an immutable value of the entire database

The performance cost is usually minimal unless this handle is held open too long. We expect clients of the BackingStore to not retain handles for a long time.

Constructors

BackingStoreValueHandle 

Fields

  • bsvhAtSlot โˆท !(WithOrigin SlotNo)

    At which slot this handle was created

  • bsvhClose โˆท !(m ())

    Close the handle

    Other methods throw exceptions if called on a closed handle. bsvhClose itself is idempotent.

  • bsvhRangeRead โˆท !(ReadHint values โ†’ RangeQuery keys โ†’ m values)
  • bsvhReadAll โˆท !(ReadHint values โ†’ m values)

    Costly read all operation, not to be used in Consensus but only in snapshot-converter executable.

  • bsvhRead โˆท !(ReadHint values โ†’ keys โ†’ m values)

    Read the given keys from the handle

    Absent keys will merely not be present in the result instead of causing a failure or an exception.

  • bsvhStat โˆท !(m Statistics)

    Retrieve statistics

Instances

Instances details
NoThunks (BackingStoreValueHandle m keys values) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

noThunks โˆท Context โ†’ BackingStoreValueHandle m keys values โ†’ IO (Maybe ThunkInfo) Source #

wNoThunks โˆท Context โ†’ BackingStoreValueHandle m keys values โ†’ IO (Maybe ThunkInfo) Source #

showTypeOf โˆท Proxy (BackingStoreValueHandle m keys values) โ†’ String Source #

castBackingStoreValueHandle โˆท โˆ€ (m โˆท Type โ†’ Type) values values' keys' keys. (Functor m, ReadHint values ~ ReadHint values') โ‡’ (values โ†’ values') โ†’ (keys' โ†’ keys) โ†’ BackingStoreValueHandle m keys values โ†’ BackingStoreValueHandle m keys' values' Source #

withBsValueHandle โˆท MonadThrow m โ‡’ BackingStore m keys values diff โ†’ (BackingStoreValueHandle m keys values โ†’ m a) โ†’ m a Source #

Query

data RangeQuery keys Source #

The arguments for a query to the backing store, it is up to the particular function that is performing the query to construct a value of this type, run the query and, if appropriate, repeat this process to do a subsequent query.

Constructors

RangeQuery 

Fields

  • rqPrev โˆท !(Maybe keys)

    The result of this range query begin at first key that is strictly greater than the greatest key in rqPrev.

    If the given set of keys is Just but contains no keys, then the query will return no results. (This is the steady-state once a looping range query reaches the end of the table.)

  • rqCount โˆท !Int

    Roughly how many values to read.

    The query may return a different number of values than this even if it has not reached the last key. The only crucial invariant is that the query only returns an empty map if there are no more keys to read on disk, or if QueryBatchSize consecutive values have been deleted in the changelog, which is extremely unlikely due to the random access pattern of the UTxO set.

Instances

Instances details
Show keys โ‡’ Show (RangeQuery keys) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

showsPrec โˆท Int โ†’ RangeQuery keys โ†’ ShowS #

show โˆท RangeQuery keys โ†’ String #

showList โˆท [RangeQuery keys] โ†’ ShowS #

Eq keys โ‡’ Eq (RangeQuery keys) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

(==) โˆท RangeQuery keys โ†’ RangeQuery keys โ†’ Bool #

(/=) โˆท RangeQuery keys โ†’ RangeQuery keys โ†’ Bool #

Statistics

data Statistics Source #

Statistics for a key-value store.

Using bsvhStat on a value handle only provides statistics for the on-disk state of a key-value store. Combine this with information from a DbChangelog to obtain statistics about a "logical" state of the key-value store. See getStatistics.

Constructors

Statistics 

Fields

Instances

Instances details
Show Statistics Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

showsPrec โˆท Int โ†’ Statistics โ†’ ShowS #

show โˆท Statistics โ†’ String #

showList โˆท [Statistics] โ†’ ShowS #

Eq Statistics Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API

Methods

(==) โˆท Statistics โ†’ Statistics โ†’ Bool #

(/=) โˆท Statistics โ†’ Statistics โ†’ Bool #

Tracing

๐Ÿงช Testing

bsRead โˆท MonadThrow m โ‡’ BackingStore m keys values diff โ†’ ReadHint values โ†’ keys โ†’ m (WithOrigin SlotNo, values) Source #

A combination of bsValueHandle and bsvhRead

bsReadAll โˆท MonadThrow m โ‡’ BackingStore m keys values diff โ†’ ReadHint values โ†’ m values Source #