Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data BlockSummary blk = BlockSummary {
- summaryEntry ∷ !(Entry blk)
- summaryBlockNo ∷ !BlockNo
- summarySlotNo ∷ !SlotNo
- data ChunkFileError blk
- = ChunkErrRead ReadIncrementalErr
- | ChunkErrHashMismatch (HeaderHash blk) (ChainHash blk)
- | ChunkErrCorrupt (Point blk)
- parseChunkFile ∷ ∀ m blk h r. (IOLike m, GetPrevHash blk, HasBinaryBlockInfo blk, DecodeDisk blk (ByteString → blk)) ⇒ CodecConfig blk → HasFS m h → (blk → Bool) → FsPath → [CRC] → (Stream (Of (BlockSummary blk, ChainHash blk)) m (Maybe (ChunkFileError blk, Word64)) → m r) → m r
Documentation
data BlockSummary blk Source #
Information about a block returned by the parser.
The fields of this record are strict to make sure that by evaluating this record to WHNF, we no longer hold on to the entire block. Otherwise, we might accidentally keep all blocks in a single file in memory during parsing.
BlockSummary | |
|
data ChunkFileError blk Source #
Defined here instead of in the Parser
module because TraceEvent
depends on it.
ChunkErrRead ReadIncrementalErr | A block could not be decoded |
ChunkErrHashMismatch | The previous hash of a block did not match the hash of the previous block. |
| |
ChunkErrCorrupt (Point blk) | The integrity verification of the block with the given point returned
|
Instances
StandardHash blk ⇒ Show (ChunkFileError blk) Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Types showsPrec ∷ Int → ChunkFileError blk → ShowS # show ∷ ChunkFileError blk → String # showList ∷ [ChunkFileError blk] → ShowS # | |
StandardHash blk ⇒ Eq (ChunkFileError blk) Source # | |
Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Types (==) ∷ ChunkFileError blk → ChunkFileError blk → Bool # (/=) ∷ ChunkFileError blk → ChunkFileError blk → Bool # |
∷ ∀ m blk h r. (IOLike m, GetPrevHash blk, HasBinaryBlockInfo blk, DecodeDisk blk (ByteString → blk)) | |
⇒ CodecConfig blk | |
→ HasFS m h | |
→ (blk → Bool) | Check integrity of the block. |
→ FsPath | |
→ [CRC] | |
→ (Stream (Of (BlockSummary blk, ChainHash blk)) m (Maybe (ChunkFileError blk, Word64)) → m r) | |
→ m r |
Parse the contents of a chunk file.
- The parser decodes each block in the chunk. When one of them fails to
decode, a
ChunkErrRead
error is returned. - Each block's checksum is checked against its given expected checksum
(coming from the secondary index). When a checksum doesn't match, a
ChunkErrCorrupt
error is returned. When the secondary index is missing or corrupt, and there are no or fewer expected checksums, we use the given (more expensive) integrity checking function instead of checksum comparison. - We check that each block fits onto the previous one by checking the hashes.
If not, we return a
ChunkErrHashMismatch
error. - An error is returned in the form of:
'Maybe' ('ChunkFileError' blk, 'Word64')
The Word64
corresponds to the offset in the file where the last valid
entry ends. Truncating to this offset will remove all invalid data from the
file and just leave the valid entries before it. Note that we are not using
Either
because the error might occur after some valid entries have been
parsed successfully, in which case we still want these valid entries, but
also want to know about the error so we can truncate the file to get rid of
the unparseable data.