Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Model for the ImmutableDB
.
Synopsis
- data DBModel blk = DBModel {
- dbmChunkInfo ∷ ChunkInfo
- dbmCodecConfig ∷ CodecConfig blk
- dbmIterators ∷ Map IteratorId (IteratorModel blk)
- dbmNextIterator ∷ IteratorId
- dbmSlots ∷ Map SlotNo (InSlot blk)
- data InSlot blk
- = InSlotBlock blk
- | InSlotEBB blk
- | InSlotBoth blk blk
- type IteratorId = Int
- data IteratorModel blk
- closeAllIterators ∷ DBModel blk → DBModel blk
- dbmBlocks ∷ DBModel blk → [blk]
- dbmCurrentChunk ∷ HasHeader blk ⇒ DBModel blk → ChunkNo
- dbmTip ∷ GetHeader blk ⇒ DBModel blk → WithOrigin (Tip blk)
- dbmTipBlock ∷ DBModel blk → WithOrigin blk
- initDBModel ∷ ChunkInfo → CodecConfig blk → DBModel blk
- simulateCorruptions ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk) ⇒ Corruptions → DBModel blk → (WithOrigin (Tip blk), DBModel blk)
- tips ∷ GetHeader blk ⇒ DBModel blk → NonEmpty (WithOrigin (Tip blk))
- appendBlockModel ∷ ∀ blk. (HasHeader blk, GetHeader blk, HasCallStack) ⇒ blk → DBModel blk → Either (ImmutableDBError blk) (DBModel blk)
- deleteAfterModel ∷ GetHeader blk ⇒ WithOrigin (Tip blk) → DBModel blk → DBModel blk
- getBlockComponentModel ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk, HasNestedContent Header blk, EncodeDiskDep (NestedCtxt Header) blk) ⇒ BlockComponent blk b → RealPoint blk → DBModel blk → Either (MissingBlock blk) b
- getHashForSlotModel ∷ HasHeader blk ⇒ SlotNo → DBModel blk → Maybe (HeaderHash blk)
- getTipModel ∷ GetHeader blk ⇒ DBModel blk → WithOrigin (Tip blk)
- iteratorCloseModel ∷ IteratorId → DBModel blk → DBModel blk
- iteratorHasNextModel ∷ HasHeader blk ⇒ IteratorId → DBModel blk → Maybe (RealPoint blk)
- iteratorNextModel ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk, HasNestedContent Header blk, EncodeDiskDep (NestedCtxt Header) blk) ⇒ IteratorId → BlockComponent blk b → DBModel blk → (IteratorResult b, DBModel blk)
- reopenModel ∷ GetHeader blk ⇒ DBModel blk → (WithOrigin (Tip blk), DBModel blk)
- streamAllModel ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk, HasNestedContent Header blk, EncodeDiskDep (NestedCtxt Header) blk) ⇒ BlockComponent blk b → DBModel blk → [b]
- streamModel ∷ ∀ blk. (HasHeader blk, GetHeader blk, HasCallStack) ⇒ StreamFrom blk → StreamTo blk → DBModel blk → Either (ImmutableDBError blk) (Either (MissingBlock blk) (IteratorId, DBModel blk))
Documentation
DBModel | |
|
Instances
InSlotBlock blk | This slot contains only a regular block |
InSlotEBB blk | This slot contains only an EBB |
InSlotBoth blk blk | This slot contains an EBB and a regular block NOTE: EBBs shares o a block number with their predecessor o a slot number with their successor So within the same slot, the EBB comes first. |
Instances
Generic (InSlot blk) Source # | |
Show blk ⇒ Show (InSlot blk) Source # | |
ToExpr (InSlot TestBlock) Source # | |
type Rep (InSlot blk) Source # | |
Defined in Test.Ouroboros.Storage.ImmutableDB.Model type Rep (InSlot blk) = D1 ('MetaData "InSlot" "Test.Ouroboros.Storage.ImmutableDB.Model" "ouroboros-consensus-0.21.0.0-inplace-storage-test" 'False) (C1 ('MetaCons "InSlotBlock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk)) :+: (C1 ('MetaCons "InSlotEBB" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk)) :+: C1 ('MetaCons "InSlotBoth" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk)))) |
type IteratorId = Int Source #
data IteratorModel blk Source #
Model for an Iterator
.
An iterator is open iff its is present in dbmIterators
.
The model of an iterator is just the list of blocks it streams over. Advancing the iterator will yield the first one and should drop it from the model.
Instances
closeAllIterators ∷ DBModel blk → DBModel blk Source #
dbmBlocks ∷ DBModel blk → [blk] Source #
Return a list of blocks in the same order as they appear on the "virtual" chain in the ImmutableDB.
dbmTipBlock ∷ DBModel blk → WithOrigin blk Source #
initDBModel ∷ ChunkInfo → CodecConfig blk → DBModel blk Source #
simulateCorruptions ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk) ⇒ Corruptions → DBModel blk → (WithOrigin (Tip blk), DBModel blk) Source #
Simulate the following: close the database, apply the corruptions to the respective files, and restore to the last valid epoch.
The resulting chain will be a prefix of the given chain.
The FsPath
s must correspond to index or epoch files that a real database,
which is in sync with the given model, would have created on disk.
Returns the new tip.
ImmutableDB implementation
appendBlockModel ∷ ∀ blk. (HasHeader blk, GetHeader blk, HasCallStack) ⇒ blk → DBModel blk → Either (ImmutableDBError blk) (DBModel blk) Source #
deleteAfterModel ∷ GetHeader blk ⇒ WithOrigin (Tip blk) → DBModel blk → DBModel blk Source #
getBlockComponentModel ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk, HasNestedContent Header blk, EncodeDiskDep (NestedCtxt Header) blk) ⇒ BlockComponent blk b → RealPoint blk → DBModel blk → Either (MissingBlock blk) b Source #
getHashForSlotModel ∷ HasHeader blk ⇒ SlotNo → DBModel blk → Maybe (HeaderHash blk) Source #
getTipModel ∷ GetHeader blk ⇒ DBModel blk → WithOrigin (Tip blk) Source #
iteratorCloseModel ∷ IteratorId → DBModel blk → DBModel blk Source #
iteratorHasNextModel ∷ HasHeader blk ⇒ IteratorId → DBModel blk → Maybe (RealPoint blk) Source #
iteratorNextModel ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk, HasNestedContent Header blk, EncodeDiskDep (NestedCtxt Header) blk) ⇒ IteratorId → BlockComponent blk b → DBModel blk → (IteratorResult b, DBModel blk) Source #
reopenModel ∷ GetHeader blk ⇒ DBModel blk → (WithOrigin (Tip blk), DBModel blk) Source #
Close all open iterators and return the current tip
streamAllModel ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk, HasNestedContent Header blk, EncodeDiskDep (NestedCtxt Header) blk) ⇒ BlockComponent blk b → DBModel blk → [b] Source #
streamModel ∷ ∀ blk. (HasHeader blk, GetHeader blk, HasCallStack) ⇒ StreamFrom blk → StreamTo blk → DBModel blk → Either (ImmutableDBError blk) (Either (MissingBlock blk) (IteratorId, DBModel blk)) Source #