ouroboros-network-0.1.0.0: A networking layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Testing.ConcreteBlock

Description

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

Documentation

data Block Source #

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.

Constructors

Block 

Instances

Instances details
Eq Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

(==)BlockBlockBool Source #

(/=)BlockBlockBool Source #

Show Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Generic Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Associated Types

type Rep BlockTypeType Source #

Methods

fromBlockRep Block x Source #

toRep Block x → Block Source #

Serialise Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

encodeBlock → Encoding #

decode ∷ Decoder s Block #

encodeList ∷ [Block] → Encoding #

decodeList ∷ Decoder s [Block] #

StandardHash Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

HasFullHeader Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

HasHeader Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

ShowProxy Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep Block Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep Block = D1 ('MetaData "Block" "Ouroboros.Network.Testing.ConcreteBlock" "ouroboros-network-0.1.0.0-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 # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

data BlockHeader Source #

A block header. It retains simplified versions of all the essential elements.

Constructors

BlockHeader 

Fields

Instances

Instances details
Eq BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Show BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Generic BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Associated Types

type Rep BlockHeaderTypeType Source #

Serialise BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

encodeBlockHeader → Encoding #

decode ∷ Decoder s BlockHeader #

encodeList ∷ [BlockHeader] → Encoding #

decodeList ∷ Decoder s [BlockHeader] #

StandardHash BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

HasFullHeader BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

HasHeader BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

ShowProxy BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep BlockHeader = D1 ('MetaData "BlockHeader" "Ouroboros.Network.Testing.ConcreteBlock" "ouroboros-network-0.1.0.0-inplace" 'False) (C1 ('MetaCons "BlockHeader" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headerHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (HeaderHash BlockHeader)) :*: S1 ('MetaSel ('Just "headerPrevHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainHash BlockHeader))) :*: (S1 ('MetaSel ('Just "headerSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Just "headerBlockNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BlockNo) :*: S1 ('MetaSel ('Just "headerBodyHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BodyHash)))))
type HeaderHash BlockHeader Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

newtype BlockBody Source #

Constructors

BlockBody ByteString 

Instances

Instances details
Eq BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Ord BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Show BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

IsString BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Generic BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Associated Types

type Rep BlockBodyTypeType Source #

Serialise BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

encodeBlockBody → Encoding #

decode ∷ Decoder s BlockBody #

encodeList ∷ [BlockBody] → Encoding #

decodeList ∷ Decoder s [BlockBody] #

Hashable BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

hashWithSaltIntBlockBodyInt

hashBlockBodyInt

type Rep BlockBody Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep BlockBody = D1 ('MetaData "BlockBody" "Ouroboros.Network.Testing.ConcreteBlock" "ouroboros-network-0.1.0.0-inplace" 'True) (C1 ('MetaCons "BlockBody" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype BodyHash Source #

The hash of all the information in a BlockBody.

Constructors

BodyHash Int 

Instances

Instances details
Eq BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Ord BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Show BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Generic BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Associated Types

type Rep BodyHashTypeType Source #

Serialise BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

encodeBodyHash → Encoding #

decode ∷ Decoder s BodyHash #

encodeList ∷ [BodyHash] → Encoding #

decodeList ∷ Decoder s [BodyHash] #

Hashable BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

hashWithSaltIntBodyHashInt

hashBodyHashInt

type Rep BodyHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep BodyHash = D1 ('MetaData "BodyHash" "Ouroboros.Network.Testing.ConcreteBlock" "ouroboros-network-0.1.0.0-inplace" 'True) (C1 ('MetaCons "BodyHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

newtype ConcreteHeaderHash Source #

The hash of all the information in a BlockHeader.

Constructors

HeaderHash Int 

Instances

Instances details
Eq ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Ord ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Show ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Generic ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Associated Types

type Rep ConcreteHeaderHashTypeType Source #

Serialise ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

encodeConcreteHeaderHash → Encoding #

decode ∷ Decoder s ConcreteHeaderHash #

encodeList ∷ [ConcreteHeaderHash] → Encoding #

decodeList ∷ Decoder s [ConcreteHeaderHash] #

NoThunks ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Methods

noThunks ∷ Context → ConcreteHeaderHashIO (Maybe ThunkInfo)

wNoThunks ∷ Context → ConcreteHeaderHashIO (Maybe ThunkInfo)

showTypeOfProxy ConcreteHeaderHashString

Hashable ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep ConcreteHeaderHash Source # 
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

type Rep ConcreteHeaderHash = D1 ('MetaData "ConcreteHeaderHash" "Ouroboros.Network.Testing.ConcreteBlock" "ouroboros-network-0.1.0.0-inplace" 'True) (C1 ('MetaCons "HeaderHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

hashBody ∷ Hashable body ⇒ body → BodyHash Source #

Converting slots to times

convertSlotToTimeForTestsAssumingNoHardForkSlotNoUTCTime 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.

Generator utilities

fixupBlockHeaderHash block ~ HeaderHash BlockHeaderAnchor block → BlockBlock 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.

fixupBlockHeaderHeaderHash block ~ HeaderHash BlockHeaderAnchor block → BlockHeaderBlockHeader 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.

fixupBlockAfterBlockBlockBlockBlock Source #

Fixup a block so to fit it on top of a given previous block.

fixupChainHasFullHeader b ⇒ (Anchor b → b → b) → [b] → Chain b Source #

Fix up the block number and hashes of a Chain. This also fixes up the first block to chain-on from genesis, since by construction the Chain type starts from genesis.

fixupAnchoredFragmentFromHasFullHeader b ⇒ Anchor b → (Anchor b → b → b) → [b] → AnchoredFragment b Source #

Orphan instances

Hashable SlotNo Source # 
Instance details

Methods

hashWithSaltIntSlotNoInt

hashSlotNoInt

Hashable BlockNo Source # 
Instance details

Methods

hashWithSaltIntBlockNoInt

hashBlockNoInt

Hashable (HeaderHash b) ⇒ Hashable (ChainHash b) Source #

Hashable instance for Hash

We don't insist that Hashable in StandardHash because Hashable is only used in the network layer tests.

This requires UndecidableInstances because Hashable (HeaderHash b) is no smaller than Hashable (ChainHash b).

Instance details

Methods

hashWithSaltIntChainHash b → Int

hashChainHash b → Int