Safe Haskell | None |
---|---|
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
Eq Block Source # | |
Show Block Source # | |
Generic Block Source # | |
Serialise Block Source # | |
StandardHash Block Source # | |
Defined in Ouroboros.Network.Testing.ConcreteBlock |
|
HasFullHeader Block Source # | |
Defined in Ouroboros.Network.Testing.ConcreteBlock |
|
HasHeader Block Source # | |
Defined in Ouroboros.Network.Testing.ConcreteBlock getHeaderFields :: Block -> HeaderFields Block Source # |
|
ShowProxy Block Source # | |
type Rep Block Source # | |
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 # | |
Defined in Ouroboros.Network.Testing.ConcreteBlock |
data BlockHeader Source #
A block header. It retains simplified versions of all the essential elements.
BlockHeader | |
|
Instances
Instances
Eq BlockBody Source # | |
Ord BlockBody Source # | |
Defined in Ouroboros.Network.Testing.ConcreteBlock |
|
Show BlockBody Source # | |
IsString BlockBody Source # | |
Defined in Ouroboros.Network.Testing.ConcreteBlock fromString :: String -> BlockBody Source # |
|
Generic BlockBody Source # | |
Hashable BlockBody Source # | |
Serialise BlockBody Source # | |
type Rep BlockBody Source # | |
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
)))
|
hashHeader :: BlockHeader -> ConcreteHeaderHash Source #
Compute the
HeaderHash
of the
BlockHeader
.
The hash of all the information in a
BlockBody
.
Instances
Eq BodyHash Source # | |
Ord BodyHash Source # | |
Defined in Ouroboros.Network.Testing.ConcreteBlock |
|
Show BodyHash Source # | |
Generic BodyHash Source # | |
Hashable BodyHash Source # | |
Serialise BodyHash Source # | |
type Rep BodyHash Source # | |
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
.
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
mkPartialBlockHeader :: SlotNo -> BlockBody -> BlockHeader Source #
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 SlotNo Source # | |
Hashable BlockNo Source # | |
Hashable ( HeaderHash b) => Hashable ( ChainHash b) Source # |
We don't insist that
This requires
|