Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type family BlockProtocol blk ∷ Type
- data family BlockConfig blk ∷ Type
- data family CodecConfig blk ∷ Type
- data family StorageConfig blk ∷ Type
- class (HasHeader blk, GetHeader blk) ⇒ GetPrevHash blk where
- headerPrevHash ∷ Header blk → ChainHash blk
- blockPrevHash ∷ GetPrevHash blk ⇒ blk → ChainHash blk
- class HasHeader (Header blk) ⇒ GetHeader blk where
- getHeader ∷ blk → Header blk
- blockMatchesHeader ∷ Header blk → blk → Bool
- headerIsEBB ∷ Header blk → Maybe EpochNo
- data family Header blk ∷ Type
- blockIsEBB ∷ GetHeader blk ⇒ blk → Maybe EpochNo
- blockToIsEBB ∷ GetHeader blk ⇒ blk → IsEBB
- getBlockHeaderFields ∷ GetHeader blk ⇒ blk → HeaderFields blk
- headerHash ∷ HasHeader (Header blk) ⇒ Header blk → HeaderHash blk
- headerPoint ∷ HasHeader (Header blk) ⇒ Header blk → Point blk
- headerToIsEBB ∷ GetHeader blk ⇒ Header blk → IsEBB
- class ConvertRawHash blk where
- toRawHash ∷ proxy blk → HeaderHash blk → ByteString
- fromRawHash ∷ proxy blk → ByteString → HeaderHash blk
- toShortRawHash ∷ proxy blk → HeaderHash blk → ShortByteString
- fromShortRawHash ∷ proxy blk → ShortByteString → HeaderHash blk
- hashSize ∷ proxy blk → Word32
- decodeRawHash ∷ ConvertRawHash blk ⇒ proxy blk → ∀ s. Decoder s (HeaderHash blk)
- encodeRawHash ∷ ConvertRawHash blk ⇒ proxy blk → HeaderHash blk → Encoding
- succWithOrigin ∷ (Bounded t, Enum t) ⇒ WithOrigin t → t
- newtype GenesisWindow = GenesisWindow {}
- data ChainHash (b ∷ k)
- = GenesisHash
- | BlockHash !(HeaderHash b)
- class (StandardHash b, Typeable b) ⇒ HasHeader b where
- getHeaderFields ∷ b → HeaderFields b
- data HeaderFields (b ∷ k) = HeaderFields {}
- type family HeaderHash (b ∷ k)
- data Point (block ∷ k) where
- pattern GenesisPoint ∷ Point block
- pattern BlockPoint ∷ SlotNo → HeaderHash block → Point block
- class (Eq (HeaderHash b), Ord (HeaderHash b), Show (HeaderHash b), Typeable (HeaderHash b), NoThunks (HeaderHash b)) ⇒ StandardHash (b ∷ k)
- blockHash ∷ HasHeader b ⇒ b → HeaderHash b
- blockNo ∷ HasHeader b ⇒ b → BlockNo
- blockPoint ∷ HasHeader block ⇒ block → Point block
- blockSlot ∷ HasHeader b ⇒ b → SlotNo
- castHash ∷ ∀ {k1} {k2} (b ∷ k1) (b' ∷ k2). Coercible (HeaderHash b) (HeaderHash b') ⇒ ChainHash b → ChainHash b'
- castHeaderFields ∷ ∀ {k1} {k2} (b ∷ k1) (b' ∷ k2). HeaderHash b ~ HeaderHash b' ⇒ HeaderFields b → HeaderFields b'
- castPoint ∷ ∀ {k1} {k2} (b ∷ k1) (b' ∷ k2). Coercible (HeaderHash b) (HeaderHash b') ⇒ Point b → Point b'
- pointHash ∷ ∀ {k} (block ∷ k). Point block → ChainHash block
- pointSlot ∷ ∀ {k} (block ∷ k). Point block → WithOrigin SlotNo
- newtype BlockNo = BlockNo {}
- newtype EpochNo = EpochNo {}
- newtype EpochSize = EpochSize {}
- newtype SlotNo = SlotNo {}
- data WithOrigin t where
- Origin
- pattern NotOrigin ∷ t → WithOrigin t
- fromWithOrigin ∷ t → WithOrigin t → t
- withOrigin ∷ b → (t → b) → WithOrigin t → b
- withOriginFromMaybe ∷ Maybe t → WithOrigin t
- withOriginToMaybe ∷ WithOrigin t → Maybe t
Protocol
type family BlockProtocol blk ∷ Type Source #
Map block to consensus protocol
Instances
type BlockProtocol (Header blk) Source # | |
Defined in Ouroboros.Consensus.Block.Abstract | |
type BlockProtocol (HardForkBlock xs) Source # | |
type BlockProtocol (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
Configuration
data family BlockConfig blk ∷ Type Source #
Static configuration required to work with this type of blocks
Instances
data family CodecConfig blk ∷ Type Source #
Static configuration required for serialisation and deserialisation of types pertaining to this type of block.
Data family instead of type family to get better type inference.
Instances
data family StorageConfig blk ∷ Type Source #
Config needed for the
NodeInitStorage
class. Defined here to
avoid circular dependencies.
Instances
Previous hash
class (HasHeader blk, GetHeader blk) ⇒ GetPrevHash blk where Source #
headerPrevHash ∷ Header blk → ChainHash blk Source #
Get the hash of the predecessor of this block
Instances
CanHardFork xs ⇒ GetPrevHash (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Block headerPrevHash ∷ Header (HardForkBlock xs) → ChainHash (HardForkBlock xs) Source # | |
Bridge m a ⇒ GetPrevHash (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
blockPrevHash ∷ GetPrevHash blk ⇒ blk → ChainHash blk Source #
Working with headers
class HasHeader (Header blk) ⇒ GetHeader blk where Source #
getHeader ∷ blk → Header blk Source #
blockMatchesHeader ∷ Header blk → blk → Bool Source #
Check whether the header is the header of the block.
For example, by checking whether the hash of the body stored in the header matches that of the block.
headerIsEBB ∷ Header blk → Maybe EpochNo Source #
When the given header is the header of an Epoch Boundary Block, returns its epoch number.
Instances
CanHardFork xs ⇒ GetHeader (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Block getHeader ∷ HardForkBlock xs → Header (HardForkBlock xs) Source # blockMatchesHeader ∷ Header (HardForkBlock xs) → HardForkBlock xs → Bool Source # headerIsEBB ∷ Header (HardForkBlock xs) → Maybe EpochNo Source # | |
Bridge m a ⇒ GetHeader (DualBlock m a) Source # | |
data family Header blk ∷ Type Source #
Instances
blockToIsEBB ∷ GetHeader blk ⇒ blk → IsEBB Source #
getBlockHeaderFields ∷ GetHeader blk ⇒ blk → HeaderFields blk Source #
Get the HeaderFields
of a block, without requiring 'HasHeader blk'
This is primarily useful as a a simple definition of HasHeader
for
block types:
instance HasHeader SomeBlock where getHeaderFields = getBlockHeaderFields
provided that there is a HasHeader
instance for the header.
Unfortunately we cannot give a HasHeader
instance once and for all; if we
mapped from a header to a block instead we could do
instance HasHeader hdr => HasHeader (Block hdr) where ..
but we can't do that when we do things this way around.
headerHash ∷ HasHeader (Header blk) ⇒ Header blk → HeaderHash blk Source #
Raw hash
class ConvertRawHash blk where Source #
Convert a hash from/to raw bytes
Variants of toRawHash
and fromRawHash
for ShortByteString
are
included. Override the default implementations to avoid an extra step in
case the HeaderHash
is a ShortByteString
under the hood.
toRawHash ∷ proxy blk → HeaderHash blk → ByteString Source #
Get the raw bytes from a hash
fromRawHash ∷ proxy blk → ByteString → HeaderHash blk Source #
Construct the hash from a raw hash
PRECONDITION: the bytestring's size must match hashSize
toShortRawHash ∷ proxy blk → HeaderHash blk → ShortByteString Source #
Variant of toRawHash
for ShortByteString
fromShortRawHash ∷ proxy blk → ShortByteString → HeaderHash blk Source #
Variant of fromRawHash
for ShortByteString
hashSize ∷ proxy blk → Word32 Source #
The size of the hash in number of bytes
Instances
decodeRawHash ∷ ConvertRawHash blk ⇒ proxy blk → ∀ s. Decoder s (HeaderHash blk) Source #
encodeRawHash ∷ ConvertRawHash blk ⇒ proxy blk → HeaderHash blk → Encoding Source #
Utilities for working with WithOrigin
succWithOrigin ∷ (Bounded t, Enum t) ⇒ WithOrigin t → t Source #
Return the successor of a WithOrigin
value. Useful in combination with
SlotNo
and BlockNo
.
Ouroboros Genesis window
newtype GenesisWindow Source #
Size of the Genesis window, in number of slots.
This is the number of slots that the GDD Governor (Genesis Density
Disconnection Governor -- see Governor
) will
consider when deciding whether to disconnect from a peer. It has to be
smaller or equal to the stability window. For instance, for Shelley-based
eras, this will be equal to a stability window, that is 3k/f
.
Instances
Num GenesisWindow Source # | |
Defined in Ouroboros.Consensus.Block.Abstract | |
Show GenesisWindow Source # | |
Defined in Ouroboros.Consensus.Block.Abstract showsPrec ∷ Int → GenesisWindow → ShowS # show ∷ GenesisWindow → String # showList ∷ [GenesisWindow] → ShowS # | |
Eq GenesisWindow Source # | |
Defined in Ouroboros.Consensus.Block.Abstract (==) ∷ GenesisWindow → GenesisWindow → Bool # (/=) ∷ GenesisWindow → GenesisWindow → Bool # | |
Ord GenesisWindow Source # | |
Defined in Ouroboros.Consensus.Block.Abstract compare ∷ GenesisWindow → GenesisWindow → Ordering # (<) ∷ GenesisWindow → GenesisWindow → Bool # (<=) ∷ GenesisWindow → GenesisWindow → Bool # (>) ∷ GenesisWindow → GenesisWindow → Bool # (>=) ∷ GenesisWindow → GenesisWindow → Bool # | |
NoThunks GenesisWindow Source # | |
Defined in Ouroboros.Consensus.Block.Abstract |
Re-export basic definitions from ouroboros-network
data ChainHash (b ∷ k) Source #
Instances
class (StandardHash b, Typeable b) ⇒ HasHeader b where Source #
Abstract over the shape of blocks (or indeed just block headers)
getHeaderFields ∷ b → HeaderFields b Source #
Instances
CanHardFork xs ⇒ HasHeader (Header (HardForkBlock xs)) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Block getHeaderFields ∷ Header (HardForkBlock xs) → HeaderFields (Header (HardForkBlock xs)) Source # | |
CanHardFork xs ⇒ HasHeader (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Block getHeaderFields ∷ HardForkBlock xs → HeaderFields (HardForkBlock xs) Source # | |
Bridge m a ⇒ HasHeader (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual getHeaderFields ∷ DualBlock m a → HeaderFields (DualBlock m a) Source # | |
Bridge m a ⇒ HasHeader (DualHeader m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual getHeaderFields ∷ DualHeader m a → HeaderFields (DualHeader m a) Source # | |
(StandardHash b, Typeable b, Typeable k) ⇒ HasHeader (HeaderFields b) | |
Defined in Ouroboros.Network.Block getHeaderFields ∷ HeaderFields b → HeaderFields (HeaderFields b) Source # |
data HeaderFields (b ∷ k) Source #
Header fields we expect to be present in a block
These fields are lazy because they are extracted from a block or block header; this type is not intended for storage.
Instances
type family HeaderHash (b ∷ k) Source #
Header hash
Instances
type HeaderHash (Header blk ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Block.Abstract | |
type HeaderHash (HardForkBlock xs ∷ Type) Source # | |
type HeaderHash (LedgerState blk ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Ledger.Basics | |
type HeaderHash (ExtLedgerState blk ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended | |
type HeaderHash (LedgerDB l ∷ Type) Source # | |
type HeaderHash (SerialisedHeader blk ∷ Type) Source # | Only needed for the |
Defined in Ouroboros.Consensus.Storage.Serialisation | |
type HeaderHash (Ticked l ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Ticked | |
type HeaderHash (DualBlock m a ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
type HeaderHash (WithPoint blk b ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Storage.ChainDB.API | |
type HeaderHash (HeaderFields b ∷ Type) | |
Defined in Ouroboros.Network.Block | |
type HeaderHash (Serialised block ∷ Type) | |
Defined in Ouroboros.Network.Block |
data Point (block ∷ k) where Source #
A point on the chain is identified by its Slot
and HeaderHash
.
The Slot
tells us where to look and the HeaderHash
either simply serves
as a check, or in some contexts it disambiguates blocks from different forks
that were in the same slot.
It's a newtype rather than a type synonym, because using a type synonym would lead to ambiguity, since HeaderHash is a non-injective type family.
pattern GenesisPoint ∷ Point block | |
pattern BlockPoint ∷ SlotNo → HeaderHash block → Point block |
Instances
ShowProxy block ⇒ ShowProxy (Point block ∷ Type) | |
Generic (Point block) | |
StandardHash block ⇒ Show (Point block) | |
StandardHash block ⇒ Eq (Point block) | |
StandardHash block ⇒ Ord (Point block) | |
StandardHash block ⇒ NoThunks (Point block) | |
Condense (HeaderHash block) ⇒ Condense (Point block) Source # | |
Serialise (HeaderHash block) ⇒ Serialise (Point block) | |
type Rep (Point block) | |
Defined in Ouroboros.Network.Block type Rep (Point block) = D1 ('MetaData "Point" "Ouroboros.Network.Block" "ouroboros-network-api-0.11.0.0-51203573fcfcfd3b2c06491320742b9da13f8f293bfcf4fc69f087b3c7b975f1" 'True) (C1 ('MetaCons "Point" 'PrefixI 'True) (S1 ('MetaSel ('Just "getPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (WithOrigin (Block SlotNo (HeaderHash block)))))) |
class (Eq (HeaderHash b), Ord (HeaderHash b), Show (HeaderHash b), Typeable (HeaderHash b), NoThunks (HeaderHash b)) ⇒ StandardHash (b ∷ k) Source #
StandardHash
summarises the constraints we want header hashes to have
Without this class we would need to write
deriving instance Eq (HeaderHash block) => Eq (ChainHash block)
That requires UndecidableInstances
; not a problem by itself, but it also
means that we can then not use deriving Eq
anywhere else for datatypes
that reference Hash
, which is very frustrating; see
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/deriving_inferred.html
Introducing the StandardHash
class avoids this problem.
Having these constraints directly as part of the HasHeader
class is
possible but libraries that use the networking layer may wish to be able to
talk about StandardHash
independently of HasHeader
since the latter may
impose yet further constraints.
Instances
HasHeader blk ⇒ StandardHash (Header blk ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Block.Abstract | |
CanHardFork xs ⇒ StandardHash (HardForkBlock xs ∷ Type) Source # | |
StandardHash blk ⇒ StandardHash (SerialisedHeader blk ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Storage.Serialisation | |
StandardHash m ⇒ StandardHash (DualBlock m a ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
StandardHash blk ⇒ StandardHash (WithPoint blk b ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Storage.ChainDB.API | |
StandardHash b ⇒ StandardHash (HeaderFields b ∷ Type) | |
Defined in Ouroboros.Network.Block | |
StandardHash block ⇒ StandardHash (Serialised block ∷ Type) | |
Defined in Ouroboros.Network.Block |
blockHash ∷ HasHeader b ⇒ b → HeaderHash b Source #
blockPoint ∷ HasHeader block ⇒ block → Point block Source #
castHash ∷ ∀ {k1} {k2} (b ∷ k1) (b' ∷ k2). Coercible (HeaderHash b) (HeaderHash b') ⇒ ChainHash b → ChainHash b' Source #
castHeaderFields ∷ ∀ {k1} {k2} (b ∷ k1) (b' ∷ k2). HeaderHash b ~ HeaderHash b' ⇒ HeaderFields b → HeaderFields b' Source #
castPoint ∷ ∀ {k1} {k2} (b ∷ k1) (b' ∷ k2). Coercible (HeaderHash b) (HeaderHash b') ⇒ Point b → Point b' Source #
Re-export basic definitions from cardano-base
The 0-based index of the block in the blockchain. BlockNo is <= SlotNo and is only equal at slot N if there is a block for every slot where N <= SlotNo.
Instances
FromJSON BlockNo | |
ToJSON BlockNo | |
Bounded BlockNo | |
Enum BlockNo | |
Defined in Cardano.Slotting.Block | |
Generic BlockNo | |
Num BlockNo | |
Show BlockNo | |
FromCBOR BlockNo | |
ToCBOR BlockNo | |
NFData BlockNo | |
Defined in Cardano.Slotting.Block | |
Eq BlockNo | |
Ord BlockNo | |
NoThunks BlockNo | |
ChainOrder BlockNo Source # | |
Defined in Ouroboros.Consensus.Protocol.Abstract type ChainOrderConfig BlockNo Source # | |
Condense BlockNo Source # | |
Serialise BlockNo | |
type Rep BlockNo | |
Defined in Cardano.Slotting.Block type Rep BlockNo = D1 ('MetaData "BlockNo" "Cardano.Slotting.Block" "cardano-slotting-0.2.0.0-9a23f79e0e302e2ea8ebe3129d51bc2e49a139397f4b8d2bbe15b983bdf6811e" 'True) (C1 ('MetaCons "BlockNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBlockNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) | |
type ChainOrderConfig BlockNo Source # | |
Defined in Ouroboros.Consensus.Protocol.Abstract |
An epoch, i.e. the number of the epoch.
Instances
FromJSON EpochNo | |
ToJSON EpochNo | |
Enum EpochNo | |
Defined in Cardano.Slotting.Slot | |
Generic EpochNo | |
Show EpochNo | |
FromCBOR EpochNo | |
ToCBOR EpochNo | |
NFData EpochNo | |
Defined in Cardano.Slotting.Slot | |
Eq EpochNo | |
Ord EpochNo | |
NoThunks EpochNo | |
Condense EpochNo Source # | |
Serialise EpochNo | |
type Rep EpochNo | |
Defined in Cardano.Slotting.Slot type Rep EpochNo = D1 ('MetaData "EpochNo" "Cardano.Slotting.Slot" "cardano-slotting-0.2.0.0-9a23f79e0e302e2ea8ebe3129d51bc2e49a139397f4b8d2bbe15b983bdf6811e" 'True) (C1 ('MetaCons "EpochNo" 'PrefixI 'True) (S1 ('MetaSel ('Just "unEpochNo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) |
Instances
FromJSON EpochSize | |
ToJSON EpochSize | |
Enum EpochSize | |
Generic EpochSize | |
Show EpochSize | |
FromCBOR EpochSize | |
ToCBOR EpochSize | |
NFData EpochSize | |
Defined in Cardano.Slotting.Slot | |
Eq EpochSize | |
Ord EpochSize | |
Defined in Cardano.Slotting.Slot | |
NoThunks EpochSize | |
type Rep EpochSize | |
Defined in Cardano.Slotting.Slot type Rep EpochSize = D1 ('MetaData "EpochSize" "Cardano.Slotting.Slot" "cardano-slotting-0.2.0.0-9a23f79e0e302e2ea8ebe3129d51bc2e49a139397f4b8d2bbe15b983bdf6811e" 'True) (C1 ('MetaCons "EpochSize" 'PrefixI 'True) (S1 ('MetaSel ('Just "unEpochSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) |
The 0-based index for the Ourboros time slot.
Instances
data WithOrigin t Source #
pattern NotOrigin ∷ t → WithOrigin t | Custom pattern for This avoids clashing with our (extensive) use of |
Instances
fromWithOrigin ∷ t → WithOrigin t → t Source #
withOrigin ∷ b → (t → b) → WithOrigin t → b Source #
withOriginFromMaybe ∷ Maybe t → WithOrigin t Source #
withOriginToMaybe ∷ WithOrigin t → Maybe t Source #