ouroboros-network-0.1.0.1: A networking layer for the Ouroboros blockchain protocol
Safe Haskell None
Language Haskell2010

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.

Instances

Instances details
Eq Block Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Show Block Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Generic Block Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Serialise Block Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

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.1-2UgqzRSdBh49QYumtriFSI" ' 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

Serialise BlockHeader Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

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 HeaderHash BlockHeader Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

newtype BlockBody Source #

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

Hashable BlockBody Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Serialise BlockBody Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

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.1-2UgqzRSdBh49QYumtriFSI" ' True ) ( C1 (' MetaCons "BlockBody" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe 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

Hashable BodyHash Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Serialise BodyHash Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

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.1-2UgqzRSdBh49QYumtriFSI" ' True ) ( C1 (' MetaCons "BodyHash" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe 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

Hashable ConcreteHeaderHash Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

NoThunks ConcreteHeaderHash Source #
Instance details

Defined in Ouroboros.Network.Testing.ConcreteBlock

Serialise 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.1-2UgqzRSdBh49QYumtriFSI" ' True ) ( C1 (' MetaCons "HeaderHash" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Int )))

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 .

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 #

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.

Orphan instances

Hashable SlotNo Source #
Instance details

Hashable BlockNo Source #
Instance details

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