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

Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

Description

A BackingStore implementation based on LMDB.

Synopsis

Opening a database

data LMDBLimits where Source #

Bundled Patterns

pattern LMDBLimitsIntIntIntLMDBLimits

Configuration to use for LMDB backing store initialisation.

Keep the following in mind:

  • lmdbMapSize should be a multiple of the OS page size.
  • lmdbMaxDatabases should be set to at least 2, since the backing store has 2 internal LMDB databases by default: 1 for the actual tables, and 1 for the database state DbSeqNo.

newLMDBBackingStore Source #

Arguments

∷ ∀ m (l ∷ LedgerStateKind). (HasCallStack, HasLedgerTables l, MonadIO m, IOLike m, MemPackIdx l EmptyMK ~ l EmptyMK) 
Tracer m BackingStoreTrace 
LMDBLimits

Configuration parameters for the LMDB database that we initialise. In case we initialise the LMDB database from an existing LMDB database, we use these same configuration parameters to open the existing LMDB database.

LiveLMDBFS m

The FS for the LMDB live database

SnapshotsFS m 
InitFrom (LedgerTables l ValuesMK) 
→ m (LedgerBackingStore m l) 

Initialise a backing store.

Errors

data LMDBErr Source #

Errors that can be thrown by LMDB.

WARNING: these errors will be thrown in IO as having a corrupt database is critical for the functioning of Consensus.

Constructors

LMDBErrNoDbSeqNo

The database state can not be found on-disk.

LMDBErrNonMonotonicSeq !(WithOrigin SlotNo) !(WithOrigin SlotNo)

The sequence number of a Db should be monotonically increasing across calls to bsWrite, since we use bsWrite to flush immutable changes. That is, we can only flush with a newer sequence number because the changes should be immutable. Note that this does not mean that values can not be changed in the future, only that we can not change values in the past.

LMDBErrInitialisingNonEmpty !String

The database table that is being initialised is non-empty.

LMDBErrInitialisingAlreadyHasState

The database that is being initialized already had a DbSeqNo table

LMDBErrNoValueHandle !Int

Trying to use a non-existing value handle.

LMDBErrUnableToReadSeqNo

Couldn't create a value handle because we couldn't read the sequence number

LMDBErrBadRead

Failed to read a value from a database table.

LMDBErrBadRangeRead

Failed to read a range of values from a database table.

LMDBErrDirExists !FilePath

A database directory should not exist already.

LMDBErrDirDoesntExist !FilePath

A database directory should exist already.

LMDBErrDirIsNotLMDB !FilePath

The directory exists but is not an LMDB directory!

LMDBErrNotADir !FsPath

What should be a directory is in fact a file

LMDBErrClosed

The database has been closed, so all backing store operations should throw an error.

Instances

Instances details
Exception LMDBErr Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

Show LMDBErr Source #

Show instance for pretty printing LMDBErrs as error messages that include: (i) an indication of the probable cause of the error, and (ii) a descriptive error message for the specific LMDBErr.

Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

Methods

showsPrecIntLMDBErrShowS #

showLMDBErrString #

showList ∷ [LMDBErr] → ShowS #

Internals exposed for snapshot-converter

newtype DbSeqNo Source #

The database state consists of only the database sequence number dbsSeq. dbsSeq represents the slot up to which we have flushed changes to disk. Note that we only flush changes to disk if they have become immutable.

Constructors

DbSeqNo 

Instances

Instances details
Generic DbSeqNo Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

Associated Types

type Rep DbSeqNo 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

type Rep DbSeqNo = D1 ('MetaData "DbSeqNo" "Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "DbSeqNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "dbsSeq") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (WithOrigin SlotNo))))

Methods

fromDbSeqNoRep DbSeqNo x #

toRep DbSeqNo x → DbSeqNo #

Show DbSeqNo Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

Methods

showsPrecIntDbSeqNoShowS #

showDbSeqNoString #

showList ∷ [DbSeqNo] → ShowS #

Serialise DbSeqNo Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

type Rep DbSeqNo Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB

type Rep DbSeqNo = D1 ('MetaData "DbSeqNo" "Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.Impl.LMDB" "ouroboros-consensus-0.26.0.0-inplace" 'True) (C1 ('MetaCons "DbSeqNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "dbsSeq") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (WithOrigin SlotNo))))

data LMDBMK k v Source #

A MapKind that represents an LMDB database handle

Constructors

LMDBMK !String !(Database k v) 

getDb ∷ ∀ (mode ∷ Mode) k v. IsMode mode ⇒ K2 String k v → Transaction mode (LMDBMK k v) Source #

initLMDBTable ∷ (IndexedMemPack idx v, MemPack k) ⇒ idx → LMDBMK k v → ValuesMK k v → Transaction 'ReadWrite (EmptyMK k v) Source #