| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Util.IndexedMemPack
Description
This module is a derivative of Data.MemPack but we provide something that will be used to " index " the serialization.
The idea is that we can use this in the Cardano block to avoid serializing a tag next to the TxOut, as the Ledger layer establishes the property that TxOuts are forwards deserializable, meaning we can read them in any later era.
Synopsis
- class IndexedMemPack (l ∷ Type → (Type → Type → Type) → Type) blk a where
- indexedPackedByteCount ∷ l blk EmptyMK → a → Int
- indexedPackM ∷ l blk EmptyMK → a → Pack s ()
- indexedUnpackM ∷ Buffer b ⇒ ∀ s. l blk EmptyMK → Unpack s b a
- indexedTypeName ∷ Proxy a → l blk EmptyMK → String
- class MemPack a where
- indexedPackByteString ∷ ∀ a l blk. (IndexedMemPack l blk a, HasCallStack) ⇒ l blk EmptyMK → a → ByteString
- indexedPackByteArray ∷ ∀ a l blk. (IndexedMemPack l blk a, HasCallStack) ⇒ Bool → l blk EmptyMK → a → ByteArray
- indexedUnpackError ∷ ∀ l blk a b. (Buffer b, IndexedMemPack l blk a, HasCallStack) ⇒ l blk EmptyMK → b → a
- indexedUnpackEither ∷ (IndexedMemPack l blk a, Buffer b, HasCallStack) ⇒ l blk EmptyMK → b → Either SomeError a
- unpackEither ∷ (MemPack a, Buffer b, HasCallStack) ⇒ b → Either SomeError a
Documentation
class IndexedMemPack (l ∷ Type → (Type → Type → Type) → Type) blk a where Source #
See MemPack.
Methods
indexedPackedByteCount ∷ l blk EmptyMK → a → Int Source #
indexedPackM ∷ l blk EmptyMK → a → Pack s () Source #
indexedUnpackM ∷ Buffer b ⇒ ∀ s. l blk EmptyMK → Unpack s b a Source #
Instances
| (txout ~ TxOut blk, IndexedMemPack LedgerState blk txout) ⇒ IndexedMemPack ExtLedgerState blk txout Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended Methods indexedPackedByteCount ∷ ExtLedgerState blk EmptyMK → txout → Int Source # indexedPackM ∷ ExtLedgerState blk EmptyMK → txout → Pack s () Source # indexedUnpackM ∷ Buffer b ⇒ ∀ s. ExtLedgerState blk EmptyMK → Unpack s b txout Source # indexedTypeName ∷ Proxy txout → ExtLedgerState blk EmptyMK → String Source # | |
| (txout ~ TxOut m, IndexedMemPack LedgerState m txout) ⇒ IndexedMemPack LedgerState (DualBlock m a) txout Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods indexedPackedByteCount ∷ LedgerState (DualBlock m a) EmptyMK → txout → Int Source # indexedPackM ∷ LedgerState (DualBlock m a) EmptyMK → txout → Pack s () Source # indexedUnpackM ∷ Buffer b ⇒ ∀ s. LedgerState (DualBlock m a) EmptyMK → Unpack s b txout Source # indexedTypeName ∷ Proxy txout → LedgerState (DualBlock m a) EmptyMK → String Source # | |
class MemPack a where Source #
Efficient serialization interface that operates directly on memory buffers.
Minimal complete definition
Methods
Name of the type that is being deserialized for error reporting. Default
implementation relies on Typeable.
packedByteCount ∷ a → Int Source #
Report the exact size in number of bytes that packed version of this type will
occupy. It is very important to get this right, otherwise packM will result in a
runtime exception. Another words this is the expected property that it should hold:
packedByteCount a == bufferByteCount (pack a)
packM ∷ a → Pack s () Source #
Write binary representation of a type into the MutableByteArray which can be
accessed with ask, whenever direct operations on it are necessary.
unpackM ∷ Buffer b ⇒ Unpack s b a Source #
Read binary representation of the type directly from the buffer, which can be
accessed with ask when necessary.
Warning - Direct reads from the buffer should be preceded with advancing the buffer offset
within MonadState by the exact number of bytes that gets consumed from that buffer.
⚠ - Violation of the above rule will lead to segfaults.
Instances
indexedPackByteString ∷ ∀ a l blk. (IndexedMemPack l blk a, HasCallStack) ⇒ l blk EmptyMK → a → ByteString Source #
indexedPackByteArray ∷ ∀ a l blk. (IndexedMemPack l blk a, HasCallStack) ⇒ Bool → l blk EmptyMK → a → ByteArray Source #
indexedUnpackError ∷ ∀ l blk a b. (Buffer b, IndexedMemPack l blk a, HasCallStack) ⇒ l blk EmptyMK → b → a Source #
indexedUnpackEither ∷ (IndexedMemPack l blk a, Buffer b, HasCallStack) ⇒ l blk EmptyMK → b → Either SomeError a Source #
unpackEither ∷ (MemPack a, Buffer b, HasCallStack) ⇒ b → Either SomeError a Source #