Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype BlockOffset = BlockOffset {}
- data BlockSize
- data Entry blk = Entry {
- blockOffset ∷ !BlockOffset
- headerOffset ∷ !HeaderOffset
- headerSize ∷ !HeaderSize
- checksum ∷ !CRC
- headerHash ∷ !(HeaderHash blk)
- blockOrEBB ∷ !BlockOrEBB
- newtype HeaderOffset = HeaderOffset {}
- newtype HeaderSize = HeaderSize {}
- appendEntry ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m) ⇒ HasFS m h → Handle h → Entry blk → m Word64
- entrySize ∷ ConvertRawHash blk ⇒ Proxy blk → Word32
- readAllEntries ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m, StandardHash blk, Typeable blk) ⇒ HasFS m h → SecondaryOffset → ChunkNo → (Entry blk → Bool) → Word64 → IsEBB → m [WithBlockSize (Entry blk)]
- readEntries ∷ ∀ m blk h t. (HasCallStack, ConvertRawHash blk, MonadThrow m, StandardHash blk, Typeable blk, Traversable t) ⇒ HasFS m h → ChunkNo → t (IsEBB, SecondaryOffset) → m (t (Entry blk, BlockSize))
- readEntry ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m, StandardHash blk, Typeable blk) ⇒ HasFS m h → ChunkNo → IsEBB → SecondaryOffset → m (Entry blk, BlockSize)
- truncateToEntry ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m) ⇒ Proxy blk → HasFS m h → ChunkNo → SecondaryOffset → m ()
- writeAllEntries ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m) ⇒ HasFS m h → ChunkNo → [Entry blk] → m ()
Documentation
newtype BlockOffset Source #
Instances
BlockSize Word32 | |
LastEntry | In case of the last entry, we don't have any entry and thus block offset after it that we can use to calculate the size of the block. |
Instances
Generic BlockSize Source # | |
Show BlockSize Source # | |
Eq BlockSize Source # | |
NoThunks BlockSize Source # | |
type Rep BlockSize Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Secondary type Rep BlockSize = D1 ('MetaData "BlockSize" "Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Secondary" "ouroboros-consensus-0.21.0.0-inplace" 'False) (C1 ('MetaCons "BlockSize" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32)) :+: C1 ('MetaCons "LastEntry" 'PrefixI 'False) (U1 ∷ Type → Type)) |
Entry | |
|
Instances
newtype HeaderOffset Source #
Instances
Storable HeaderOffset Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Secondary sizeOf ∷ HeaderOffset → Int # alignment ∷ HeaderOffset → Int # peekElemOff ∷ Ptr HeaderOffset → Int → IO HeaderOffset # pokeElemOff ∷ Ptr HeaderOffset → Int → HeaderOffset → IO () # peekByteOff ∷ Ptr b → Int → IO HeaderOffset # pokeByteOff ∷ Ptr b → Int → HeaderOffset → IO () # peek ∷ Ptr HeaderOffset → IO HeaderOffset # poke ∷ Ptr HeaderOffset → HeaderOffset → IO () # | |
Show HeaderOffset Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Secondary showsPrec ∷ Int → HeaderOffset → ShowS # show ∷ HeaderOffset → String # showList ∷ [HeaderOffset] → ShowS # | |
Binary HeaderOffset Source # | |
Eq HeaderOffset Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Secondary (==) ∷ HeaderOffset → HeaderOffset → Bool # (/=) ∷ HeaderOffset → HeaderOffset → Bool # | |
NoThunks HeaderOffset Source # | |
newtype HeaderSize Source #
Instances
Storable HeaderSize Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Secondary sizeOf ∷ HeaderSize → Int # alignment ∷ HeaderSize → Int # peekElemOff ∷ Ptr HeaderSize → Int → IO HeaderSize # pokeElemOff ∷ Ptr HeaderSize → Int → HeaderSize → IO () # peekByteOff ∷ Ptr b → Int → IO HeaderSize # pokeByteOff ∷ Ptr b → Int → HeaderSize → IO () # peek ∷ Ptr HeaderSize → IO HeaderSize # poke ∷ Ptr HeaderSize → HeaderSize → IO () # | |
Show HeaderSize Source # | |
Binary HeaderSize Source # | |
Eq HeaderSize Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index.Secondary (==) ∷ HeaderSize → HeaderSize → Bool # (/=) ∷ HeaderSize → HeaderSize → Bool # | |
NoThunks HeaderSize Source # | |
∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m) | |
⇒ HasFS m h | |
→ Handle h | |
→ Entry blk | |
→ m Word64 | The number of bytes written |
∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m, StandardHash blk, Typeable blk) | |
⇒ HasFS m h | |
→ SecondaryOffset | Start from this offset |
→ ChunkNo | |
→ (Entry blk → Bool) | Stop condition: stop after this entry |
→ Word64 | The size of the chunk file, used to compute the size of the last block. |
→ IsEBB | Is the first entry to read an EBB? |
→ m [WithBlockSize (Entry blk)] |
Read all entries in a secondary index file, starting from the given
SecondaryOffset
until the stop condition is true or until the end of the
file is reached. The entry for which the stop condition is true will be the
last in the returned list of entries.
readEntries ∷ ∀ m blk h t. (HasCallStack, ConvertRawHash blk, MonadThrow m, StandardHash blk, Typeable blk, Traversable t) ⇒ HasFS m h → ChunkNo → t (IsEBB, SecondaryOffset) → m (t (Entry blk, BlockSize)) Source #
Same as readEntry
, but for multiple entries.
NOTE: only use this for a few entries, as we will seek (pread
) for each
entry. Use readAllEntries
if you want to read all entries in the
secondary index file.
readEntry ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m, StandardHash blk, Typeable blk) ⇒ HasFS m h → ChunkNo → IsEBB → SecondaryOffset → m (Entry blk, BlockSize) Source #
Read the entry at the given SecondaryOffset
. Interpret it as an EBB
depending on the given IsEBB
.
truncateToEntry ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m) ⇒ Proxy blk → HasFS m h → ChunkNo → SecondaryOffset → m () Source #
Remove all entries after the entry at the given SecondaryOffset
. That
entry will now be the last entry in the secondary index file.
writeAllEntries ∷ ∀ m blk h. (HasCallStack, ConvertRawHash blk, MonadThrow m) ⇒ HasFS m h → ChunkNo → [Entry blk] → m () Source #