Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Concrete block
The network library should not export a concrete block type at all, except that it might need one in its tests (but not exported). Right now this module serves to isolate this in a specific module so we can identify easily where it is used; eventually it should be simplified and then moved to the network layer tests; the more sophiscated block abstraction (abstracted over an Ouroboros protocol) will live in the consensus layer.
Synopsis
- data Block = Block {}
- data BlockHeader = BlockHeader {}
- newtype BlockBody = BlockBody ByteString
- hashHeader ∷ BlockHeader → ConcreteHeaderHash
- newtype BodyHash = BodyHash Int
- newtype ConcreteHeaderHash = HeaderHash Int
- hashBody ∷ Hashable body ⇒ body → BodyHash
- convertSlotToTimeForTestsAssumingNoHardFork ∷ SlotNo → UTCTime
- mkChain ∷ [(SlotNo, BlockBody)] → Chain Block
- mkChainSimple ∷ [BlockBody] → Chain Block
- mkAnchoredFragment ∷ Anchor Block → [(SlotNo, BlockBody)] → AnchoredFragment Block
- mkAnchoredFragmentSimple ∷ [BlockBody] → AnchoredFragment Block
- mkPartialBlock ∷ SlotNo → BlockBody → Block
- mkPartialBlockHeader ∷ SlotNo → BlockBody → BlockHeader
- fixupBlock ∷ HeaderHash block ~ HeaderHash BlockHeader ⇒ Anchor block → Block → Block
- fixupBlockHeader ∷ HeaderHash block ~ HeaderHash BlockHeader ⇒ Anchor block → BlockHeader → BlockHeader
- fixupBlockAfterBlock ∷ Block → Block → Block
- fixupChain ∷ HasFullHeader b ⇒ (Anchor b → b → b) → [b] → Chain b
- fixupAnchoredFragmentFrom ∷ HasFullHeader b ⇒ Anchor b → (Anchor b → b → b) → [b] → AnchoredFragment b
Documentation
Our highly-simplified version of a block. It retains the separation between a block header and body, which is a detail needed for the protocols.
Instances
Generic Block Source # | |
Show Block Source # | |
Eq Block Source # | |
HasFullHeader Block Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock | |
HasHeader Block Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock | |
Serialise Block Source # | |
StandardHash Block Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock | |
ShowProxy Block Source # | |
type Rep Block Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock type Rep Block = D1 ('MetaData "Block" "Ouroboros.Network.Mock.ConcreteBlock" "ouroboros-network-mock-0.1.1.1-inplace" 'False) (C1 ('MetaCons "Block" 'PrefixI 'True) (S1 ('MetaSel ('Just "blockHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlockHeader) :*: S1 ('MetaSel ('Just "blockBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlockBody))) | |
type HeaderHash Block Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock |
data BlockHeader Source #
A block header. It retains simplified versions of all the essential elements.
BlockHeader | |
|
Instances
Instances
IsString BlockBody Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock fromString ∷ String → BlockBody # | |
Generic BlockBody Source # | |
Show BlockBody Source # | |
Eq BlockBody Source # | |
Ord BlockBody Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock | |
Hashable BlockBody Source # | |
Serialise BlockBody Source # | |
type Rep BlockBody Source # | |
Defined in Ouroboros.Network.Mock.ConcreteBlock type Rep BlockBody = D1 ('MetaData "BlockBody" "Ouroboros.Network.Mock.ConcreteBlock" "ouroboros-network-mock-0.1.1.1-inplace" 'True) (C1 ('MetaCons "BlockBody" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
hashHeader ∷ BlockHeader → ConcreteHeaderHash Source #
Compute the ConcreteHeaderHash
of the BlockHeader
.
The hash of all the information in a BlockBody
.
newtype ConcreteHeaderHash Source #
The hash of all the information in a BlockHeader
.
Instances
Converting slots to times
convertSlotToTimeForTestsAssumingNoHardFork ∷ SlotNo → UTCTime Source #
Arbitrarily but consistently converts slots UTCTimes.
It is only intended for use in tests. Notably it assumes a fixed system start time, slot length, and the absence of a hard fork (ie no HardForkCombinator). This is how it's available as a pure function.
Creating sample chains
mkChain ∷ [(SlotNo, BlockBody)] → Chain Block Source #
This takes the blocks in order from oldest to newest.
mkAnchoredFragment ∷ Anchor Block → [(SlotNo, BlockBody)] → AnchoredFragment Block Source #
Generator utilities
fixupBlock ∷ HeaderHash block ~ HeaderHash BlockHeader ⇒ Anchor block → Block → Block Source #
Fix up a block so that it fits on top of the given anchor. Only the block number, the previous hash and the block hash are updated; the slot number and the signers are kept intact.
fixupBlockHeader ∷ HeaderHash block ~ HeaderHash BlockHeader ⇒ Anchor block → BlockHeader → BlockHeader Source #
Fixup block header to fit it on top of a chain. Only block number and previous hash are updated; the slot and signer are kept unchanged.
fixupBlockAfterBlock ∷ Block → Block → Block Source #
Fixup a block so to fit it on top of a given previous block.
fixupChain ∷ HasFullHeader b ⇒ (Anchor b → b → b) → [b] → Chain b Source #
fixupAnchoredFragmentFrom ∷ HasFullHeader b ⇒ Anchor b → (Anchor b → b → b) → [b] → AnchoredFragment b Source #
Orphan instances
Hashable BlockNo Source # | |
Hashable SlotNo Source # | |
(StandardHash b, Hashable (HeaderHash b)) ⇒ Hashable (ChainHash b) Source # |
We don't insist that This requires |