storage-test
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Ouroboros.Storage.ImmutableDB.Model

Description

Model for the ImmutableDB.

Synopsis

Documentation

data DBModel blk Source #

Instances

Instances details
Generic (DBModel blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

Associated Types

type Rep (DBModel blk) ∷ TypeType #

Methods

fromDBModel blk → Rep (DBModel blk) x #

toRep (DBModel blk) x → DBModel blk #

(Show (CodecConfig blk), StandardHash blk, Show blk) ⇒ Show (DBModel blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

Methods

showsPrecIntDBModel blk → ShowS #

showDBModel blk → String #

showList ∷ [DBModel blk] → ShowS #

ToExpr (DBModel TestBlock) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

type Rep (DBModel blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

type Rep (DBModel blk) = D1 ('MetaData "DBModel" "Test.Ouroboros.Storage.ImmutableDB.Model" "ouroboros-consensus-0.21.0.0-inplace-storage-test" 'False) (C1 ('MetaCons "DBModel" 'PrefixI 'True) ((S1 ('MetaSel ('Just "dbmChunkInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChunkInfo) :*: S1 ('MetaSel ('Just "dbmCodecConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CodecConfig blk))) :*: (S1 ('MetaSel ('Just "dbmIterators") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map IteratorId (IteratorModel blk))) :*: (S1 ('MetaSel ('Just "dbmNextIterator") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IteratorId) :*: S1 ('MetaSel ('Just "dbmSlots") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map SlotNo (InSlot blk)))))))

data InSlot blk Source #

Constructors

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

Instances details
Generic (InSlot blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

Associated Types

type Rep (InSlot blk) ∷ TypeType #

Methods

fromInSlot blk → Rep (InSlot blk) x #

toRep (InSlot blk) x → InSlot blk #

Show blk ⇒ Show (InSlot blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

Methods

showsPrecIntInSlot blk → ShowS #

showInSlot blk → String #

showList ∷ [InSlot blk] → ShowS #

ToExpr (InSlot TestBlock) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

type Rep (InSlot blk) Source # 
Instance details

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 ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk)) :+: (C1 ('MetaCons "InSlotEBB" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk)) :+: C1 ('MetaCons "InSlotBoth" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 blk))))

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

Instances details
Generic (IteratorModel blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

Associated Types

type Rep (IteratorModel blk) ∷ TypeType #

Methods

fromIteratorModel blk → Rep (IteratorModel blk) x #

toRep (IteratorModel blk) x → IteratorModel blk #

Show blk ⇒ Show (IteratorModel blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

Methods

showsPrecIntIteratorModel blk → ShowS #

showIteratorModel blk → String #

showList ∷ [IteratorModel blk] → ShowS #

Eq blk ⇒ Eq (IteratorModel blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

Methods

(==)IteratorModel blk → IteratorModel blk → Bool #

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

ToExpr (IteratorModel TestBlock) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

type Rep (IteratorModel blk) Source # 
Instance details

Defined in Test.Ouroboros.Storage.ImmutableDB.Model

type Rep (IteratorModel blk) = D1 ('MetaData "IteratorModel" "Test.Ouroboros.Storage.ImmutableDB.Model" "ouroboros-consensus-0.21.0.0-inplace-storage-test" 'True) (C1 ('MetaCons "IteratorModel" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [blk])))

dbmBlocksDBModel blk → [blk] Source #

Return a list of blocks in the same order as they appear on the "virtual" chain in the ImmutableDB.

dbmTipGetHeader blk ⇒ DBModel blk → WithOrigin (Tip blk) Source #

simulateCorruptions ∷ (HasHeader blk, GetHeader blk, EncodeDisk blk blk) ⇒ CorruptionsDBModel 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 FsPaths 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.

tipsGetHeader blk ⇒ DBModel blk → NonEmpty (WithOrigin (Tip blk)) Source #

List all Tips that point to a filled slot or an existing EBB in the model, including Origin. The tips will be sorted from old to recent.

ImmutableDB implementation

appendBlockModel ∷ ∀ blk. (HasHeader blk, GetHeader blk, HasCallStack) ⇒ blk → DBModel blk → Either (ImmutableDBError blk) (DBModel blk) Source #

deleteAfterModelGetHeader blk ⇒ WithOrigin (Tip blk) → DBModel blk → DBModel blk Source #

getTipModelGetHeader blk ⇒ DBModel blk → WithOrigin (Tip blk) Source #

reopenModelGetHeader blk ⇒ DBModel blk → (WithOrigin (Tip blk), DBModel blk) Source #

Close all open iterators and return the current tip

streamModel ∷ ∀ blk. (HasHeader blk, GetHeader blk, HasCallStack) ⇒ StreamFrom blk → StreamTo blk → DBModel blk → Either (ImmutableDBError blk) (Either (MissingBlock blk) (IteratorId, DBModel blk)) Source #