ouroboros-consensus-0.1.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.ImmutableDB.Impl.Util

Contents

Synopsis

Utilities

data Two a Source #

Useful when you have exactly two values of some type and want to traverse over both of them (which is not possible with a tuple).

Constructors

Two a a 

Instances

Instances details
Functor Two Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Util

Methods

fmap ∷ (a → b) → Two a → Two b Source #

(<$) ∷ a → Two b → Two a Source #

Foldable Two Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Util

Methods

foldMonoid m ⇒ Two m → m Source #

foldMapMonoid m ⇒ (a → m) → Two a → m Source #

foldMap'Monoid m ⇒ (a → m) → Two a → m Source #

foldr ∷ (a → b → b) → b → Two a → b Source #

foldr' ∷ (a → b → b) → b → Two a → b Source #

foldl ∷ (b → a → b) → b → Two a → b Source #

foldl' ∷ (b → a → b) → b → Two a → b Source #

foldr1 ∷ (a → a → a) → Two a → a Source #

foldl1 ∷ (a → a → a) → Two a → a Source #

toListTwo a → [a] Source #

nullTwo a → Bool Source #

lengthTwo a → Int Source #

elemEq a ⇒ a → Two a → Bool Source #

maximumOrd a ⇒ Two a → a Source #

minimumOrd a ⇒ Two a → a Source #

sumNum a ⇒ Two a → a Source #

productNum a ⇒ Two a → a Source #

Traversable Two Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Impl.Util

Methods

traverseApplicative f ⇒ (a → f b) → Two a → f (Two b) Source #

sequenceAApplicative f ⇒ Two (f a) → f (Two a) Source #

mapMMonad m ⇒ (a → m b) → Two a → m (Two b) Source #

sequenceMonad m ⇒ Two (m a) → m (Two a) Source #

checkChecksum Source #

Arguments

∷ (HasCallStack, HasHeader blk, MonadThrow m) 
FsPath 
RealPoint blk 
CRC

Expected checksum

CRC

Actual checksum

→ m () 

Check whether the given checksums match. If not, throw a ChecksumMismatchError.

dbFilesOnDiskSet String → (Set ChunkNo, Set ChunkNo, Set ChunkNo) Source #

Go through all files, making three sets: the set of chunk files, primary index files, and secondary index files, discarding all others.

parseDBFileStringMaybe (String, ChunkNo) Source #

Parse the prefix and chunk number from the filename of an index or chunk file.

parseDBFile "00001.chunk"

Just ("chunk", 1) > parseDBFile "00012.primary" Just ("primary", 12)

removeFilesStartingFrom ∷ (HasCallStack, Monad m) ⇒ HasFS m h → ChunkNo → m () Source #

Remove all chunk and index starting from the given chunk (included).

renderFileTextChunkNoFsPath Source #

Opposite of parseDBFile.

runGet ∷ ∀ blk a m. (HasCallStack, MonadThrow m, StandardHash blk, Typeable blk) ⇒ Proxy blk → FsPathGet a → ByteString → m a Source #

Wrapper around runGetOrFail that throws an InvalidFileError when it failed or when there was unconsumed input.

runGetWithUnconsumed ∷ ∀ blk a m. (HasCallStack, MonadThrow m, StandardHash blk, Typeable blk) ⇒ Proxy blk → FsPathGet a → ByteString → m (ByteString, a) Source #

Same as runGet, but allows unconsumed input and returns it.

tryImmutableDB ∷ ∀ m blk a. (MonadCatch m, StandardHash blk, Typeable blk) ⇒ Proxy blk → m a → m (Either (ImmutableDBError blk) a) Source #

Execute an action and catch the ImmutableDBError and FsError that can be thrown by it, and wrap the FsError in an ImmutableDBError using the FileSystemError constructor.

This should be used whenever you want to run an action on the ImmutableDB and catch the ImmutableDBError and the FsError (wrapped in the former) it may thrown.

wrapFsError ∷ ∀ blk m a. (MonadCatch m, StandardHash blk, Typeable blk) ⇒ Proxy blk → m a → m a Source #