| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- newtype LiveLMDBFS (m ∷ Type → Type) = LiveLMDBFS {
- liveLMDBFs ∷ SomeHasFS m
- newtype SnapshotsFS (m ∷ Type → Type) = SnapshotsFS {
- snapshotsFs ∷ SomeHasFS m
- data BackingStore (m ∷ Type → Type) keys key values diff = BackingStore {
- bsClose ∷ !(m ())
- bsCopy ∷ !(SerializeTablesHint values → FsPath → m ())
- bsValueHandle ∷ !(m (BackingStoreValueHandle m keys key values))
- bsWrite ∷ !(SlotNo → WriteHint diff → diff → m ())
- bsSnapshotBackend ∷ !SnapshotBackend
- type BackingStore' (m ∷ Type → Type) blk = LedgerBackingStore m (ExtLedgerState blk)
- data DiffsToFlush (l ∷ LedgerStateKind) = DiffsToFlush {
- toFlushDiffs ∷ !(LedgerTables l DiffMK)
- toFlushState ∷ !(l EmptyMK, l EmptyMK)
- toFlushSlot ∷ !SlotNo
- data InitFrom values
- = InitFromValues !(WithOrigin SlotNo) !(InitHint values) !values
- | InitFromCopy !(InitHint values) !FsPath
- type family InitHint values
- type LedgerBackingStore (m ∷ Type → Type) (l ∷ LedgerStateKind) = BackingStore m (LedgerTables l KeysMK) (TxIn l) (LedgerTables l ValuesMK) (LedgerTables l DiffMK)
- type family ReadHint values
- type family WriteHint diffs
- data BackingStoreValueHandle (m ∷ Type → Type) keys key values = BackingStoreValueHandle {
- bsvhAtSlot ∷ !(WithOrigin SlotNo)
- bsvhClose ∷ !(m ())
- bsvhRangeRead ∷ !(ReadHint values → RangeQuery keys → m (values, Maybe key))
- bsvhReadAll ∷ !(ReadHint values → m values)
- bsvhRead ∷ !(ReadHint values → keys → m values)
- bsvhStat ∷ !(m Statistics)
- type BackingStoreValueHandle' (m ∷ Type → Type) blk = LedgerBackingStoreValueHandle m (ExtLedgerState blk)
- type LedgerBackingStoreValueHandle (m ∷ Type → Type) (l ∷ LedgerStateKind) = BackingStoreValueHandle m (LedgerTables l KeysMK) (TxIn l) (LedgerTables l ValuesMK)
- castBackingStoreValueHandle ∷ ∀ (m ∷ Type → Type) values values' keys' keys key key'. (Functor m, ReadHint values ~ ReadHint values') ⇒ (values → values') → (keys' → keys) → (key → key') → BackingStoreValueHandle m keys key values → BackingStoreValueHandle m keys' key' values'
- withBsValueHandle ∷ MonadThrow m ⇒ BackingStore m keys key values diff → (BackingStoreValueHandle m keys key values → m a) → m a
- data RangeQuery keys = RangeQuery {}
- data Statistics = Statistics {
- sequenceNumber ∷ !(WithOrigin SlotNo)
- numEntries ∷ !Int
- data BackingStoreTrace
- = BSOpening
- | BSOpened !(Maybe FsPath)
- | BSInitialisingFromCopy !FsPath
- | BSInitialisedFromCopy !FsPath
- | BSInitialisingFromValues !(WithOrigin SlotNo)
- | BSInitialisedFromValues !(WithOrigin SlotNo)
- | BSClosing
- | BSAlreadyClosed
- | BSClosed
- | BSCopying !FsPath
- | BSCopied !FsPath
- | BSCreatingValueHandle
- | BSValueHandleTrace !(Maybe Int) !BackingStoreValueHandleTrace
- | BSCreatedValueHandle
- | BSWriting !SlotNo
- | BSWritten !(WithOrigin SlotNo) !SlotNo
- data BackingStoreValueHandleTrace
- bsRead ∷ MonadThrow m ⇒ BackingStore m keys key values diff → ReadHint values → keys → m (WithOrigin SlotNo, values)
- bsReadAll ∷ MonadThrow m ⇒ BackingStore m keys key values diff → ReadHint values → m values
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
| Generic (LiveLMDBFS m) Source # | |||||
Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API Associated Types
| |||||
| NoThunks (LiveLMDBFS m) Source # | |||||
| type Rep (LiveLMDBFS m) Source # | |||||
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.28.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
| Generic (SnapshotsFS m) Source # | |||||
Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API Associated Types
| |||||
| NoThunks (SnapshotsFS m) Source # | |||||
| type Rep (SnapshotsFS m) Source # | |||||
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.28.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 key values diff Source #
Constructors
| BackingStore | |
Fields
| |
Instances
| NoThunks (BackingStore m keys key values diff) 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
| |
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
| type InitHint (LedgerTables l ValuesMK) Source # | |
type LedgerBackingStore (m ∷ Type → Type) (l ∷ LedgerStateKind) = BackingStore m (LedgerTables l KeysMK) (TxIn l) (LedgerTables l ValuesMK) (LedgerTables l DiffMK) Source #
type family ReadHint values Source #
Instances
| type ReadHint (LedgerTables l ValuesMK) Source # | |
type family WriteHint diffs Source #
Instances
| type WriteHint (LedgerTables l DiffMK) Source # | |
Value handle
data BackingStoreValueHandle (m ∷ Type → Type) keys key 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
| |
Instances
| NoThunks (BackingStoreValueHandle m keys key values) Source # | |
type BackingStoreValueHandle' (m ∷ Type → Type) blk = LedgerBackingStoreValueHandle m (ExtLedgerState blk) Source #
type LedgerBackingStoreValueHandle (m ∷ Type → Type) (l ∷ LedgerStateKind) = BackingStoreValueHandle m (LedgerTables l KeysMK) (TxIn l) (LedgerTables l ValuesMK) Source #
castBackingStoreValueHandle ∷ ∀ (m ∷ Type → Type) values values' keys' keys key key'. (Functor m, ReadHint values ~ ReadHint values') ⇒ (values → values') → (keys' → keys) → (key → key') → BackingStoreValueHandle m keys key values → BackingStoreValueHandle m keys' key' values' Source #
withBsValueHandle ∷ MonadThrow m ⇒ BackingStore m keys key values diff → (BackingStoreValueHandle m keys key values → m a) → m a Source #
A bracketed bsValueHandle
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
| |
Instances
| Show keys ⇒ Show (RangeQuery keys) Source # | |
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 # | |
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
| Show Statistics Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API Methods showsPrec ∷ Int → Statistics → ShowS # show ∷ Statistics → String # showList ∷ [Statistics] → ShowS # | |
| Eq Statistics Source # | |
Tracing
data BackingStoreTrace Source #
Constructors
Instances
| Show BackingStoreTrace Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API Methods showsPrec ∷ Int → BackingStoreTrace → ShowS # show ∷ BackingStoreTrace → String # showList ∷ [BackingStoreTrace] → ShowS # | |
| Eq BackingStoreTrace Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API Methods | |
data BackingStoreValueHandleTrace Source #
Constructors
| BSVHClosing | |
| BSVHAlreadyClosed | |
| BSVHClosed | |
| BSVHRangeReading | |
| BSVHRangeRead | |
| BSVHReading | |
| BSVHRead | |
| BSVHStatting | |
| BSVHStatted |
🧪 Testing
bsRead ∷ MonadThrow m ⇒ BackingStore m keys key values diff → ReadHint values → keys → m (WithOrigin SlotNo, values) Source #
A combination of bsValueHandle and bsvhRead
bsReadAll ∷ MonadThrow m ⇒ BackingStore m keys key values diff → ReadHint values → m values Source #