| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Block.Abstract
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
- data family Header blk :: Type
- class HasHeader (Header blk) => GetHeader blk where
- getHeader :: blk -> Header blk
- blockMatchesHeader :: Header blk -> blk -> Bool
- headerIsEBB :: Header blk -> Maybe EpochNo
- 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
- blockIsEBB :: GetHeader blk => blk -> Maybe EpochNo
- blockToIsEBB :: GetHeader blk => 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
- encodeRawHash :: ConvertRawHash blk => proxy blk -> HeaderHash blk -> Encoding
- decodeRawHash :: ConvertRawHash blk => proxy blk -> forall s. Decoder s (HeaderHash blk)
- succWithOrigin :: (Bounded t, Enum t) => WithOrigin t -> t
- blockHash :: HasHeader b => b -> HeaderHash b
- blockMeasure :: HasHeader b => b -> BlockMeasure
- data BlockMeasure
- blockNo :: HasHeader b => b -> BlockNo
- blockPoint :: HasHeader block => block -> Point block
- blockSlot :: HasHeader b => b -> SlotNo
- castHash :: Coercible (HeaderHash b) (HeaderHash b') => ChainHash b -> ChainHash b'
- castHeaderFields :: HeaderHash b ~ HeaderHash b' => HeaderFields b -> HeaderFields b'
- castPoint :: Coercible (HeaderHash b) (HeaderHash b') => Point b -> Point b'
- data ChainHash b
- = GenesisHash
- | BlockHash !(HeaderHash b)
- class (StandardHash b, Measured BlockMeasure b, Typeable b) => HasHeader b where
- getHeaderFields :: b -> HeaderFields b
- data HeaderFields b = HeaderFields {}
- type family HeaderHash b
- data Point block where
- pattern GenesisPoint :: Point block
- pattern BlockPoint :: SlotNo -> HeaderHash block -> Point block
- pointHash :: Point block -> ChainHash block
- pointSlot :: Point block -> WithOrigin SlotNo
- class (Eq (HeaderHash b), Ord (HeaderHash b), Show (HeaderHash b), Typeable (HeaderHash b), NoThunks (HeaderHash b)) => StandardHash b
- newtype BlockNo = BlockNo {}
- newtype EpochNo = EpochNo {}
- newtype EpochSize = EpochSize {}
- fromWithOrigin :: t -> WithOrigin t -> t
- newtype SlotNo = SlotNo {}
- withOrigin :: b -> (t -> b) -> WithOrigin t -> b
- withOriginFromMaybe :: Maybe t -> WithOrigin t
- data WithOrigin t where
- Origin
- pattern NotOrigin :: 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
| Isomorphic BlockConfig Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Unary Methods project :: NoHardForks blk => BlockConfig (HardForkBlock '[blk]) -> BlockConfig blk Source # inject :: NoHardForks blk => BlockConfig blk -> BlockConfig (HardForkBlock '[blk]) Source # | |
| NoThunks (BlockConfig (DualBlock m a)) Source # | |
| CanHardFork xs => NoThunks (BlockConfig (HardForkBlock xs)) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Basics Methods noThunks :: Context -> BlockConfig (HardForkBlock xs) -> IO (Maybe ThunkInfo) Source # wNoThunks :: Context -> BlockConfig (HardForkBlock xs) -> IO (Maybe ThunkInfo) Source # showTypeOf :: Proxy (BlockConfig (HardForkBlock xs)) -> String Source # | |
| newtype BlockConfig (HardForkBlock xs) Source # | |
| data BlockConfig (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
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 #
Methods
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 Methods 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
data family Header blk :: Type Source #
Instances
class HasHeader (Header blk) => GetHeader blk where Source #
Methods
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 Methods 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 # | |
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 #
blockToIsEBB :: GetHeader blk => blk -> IsEBB 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.
Minimal complete definition
hashSize, (toRawHash | toShortRawHash), (fromRawHash | fromShortRawHash)
Methods
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
encodeRawHash :: ConvertRawHash blk => proxy blk -> HeaderHash blk -> Encoding Source #
decodeRawHash :: ConvertRawHash blk => proxy blk -> forall s. Decoder s (HeaderHash blk) 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.
Re-export basic definitions from ouroboros-network
blockHash :: HasHeader b => b -> HeaderHash b #
blockMeasure :: HasHeader b => b -> BlockMeasure #
data BlockMeasure #
Instances
blockPoint :: HasHeader block => block -> Point block #
castHash :: Coercible (HeaderHash b) (HeaderHash b') => ChainHash b -> ChainHash b' #
castHeaderFields :: HeaderHash b ~ HeaderHash b' => HeaderFields b -> HeaderFields b' #
castPoint :: Coercible (HeaderHash b) (HeaderHash b') => Point b -> Point b' #
Constructors
| GenesisHash | |
| BlockHash !(HeaderHash b) |
Instances
class (StandardHash b, Measured BlockMeasure b, Typeable b) => HasHeader b where #
Methods
getHeaderFields :: b -> HeaderFields b #
Instances
| (StandardHash b, Typeable b) => HasHeader (HeaderFields b) | |
Defined in Ouroboros.Network.Block Methods getHeaderFields :: HeaderFields b -> HeaderFields (HeaderFields b) # | |
| CanHardFork xs => HasHeader (Header (HardForkBlock xs)) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Block Methods getHeaderFields :: Header (HardForkBlock xs) -> HeaderFields (Header (HardForkBlock xs)) # | |
| CanHardFork xs => HasHeader (HardForkBlock xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Block Methods getHeaderFields :: HardForkBlock xs -> HeaderFields (HardForkBlock xs) # | |
| Bridge m a => HasHeader (DualHeader m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods getHeaderFields :: DualHeader m a -> HeaderFields (DualHeader m a) # | |
| Bridge m a => HasHeader (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods getHeaderFields :: DualBlock m a -> HeaderFields (DualBlock m a) # | |
data HeaderFields b #
Constructors
| HeaderFields | |
Fields | |
Instances
type family HeaderHash b #
Instances
| type HeaderHash (HeaderFields b) | |
Defined in Ouroboros.Network.Block | |
| type HeaderHash (Serialised block) | |
Defined in Ouroboros.Network.Block | |
| type HeaderHash (Ticked l) Source # | |
Defined in Ouroboros.Consensus.Ledger.Basics | |
| type HeaderHash (Header blk) Source # | |
Defined in Ouroboros.Consensus.Block.Abstract | |
| type HeaderHash (LedgerState blk) Source # | |
Defined in Ouroboros.Consensus.Ledger.Basics | |
| type HeaderHash (ExtLedgerState blk) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended | |
| type HeaderHash (SerialisedHeader blk) Source # | Only needed for the |
Defined in Ouroboros.Consensus.Storage.Serialisation | |
| type HeaderHash (HardForkBlock xs) Source # | |
| type HeaderHash (LedgerDB l r) Source # | |
| type HeaderHash (WithPoint blk b) Source # | |
Defined in Ouroboros.Consensus.Storage.ChainDB.API | |
| type HeaderHash (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
Bundled Patterns
| pattern GenesisPoint :: Point block | |
| pattern BlockPoint :: SlotNo -> HeaderHash block -> Point block |
Instances
| StandardHash block => Eq (Point block) | |
| StandardHash block => Ord (Point block) | |
Defined in Ouroboros.Network.Block | |
| StandardHash block => Show (Point block) | |
| Generic (Point block) | |
| StandardHash block => NoThunks (Point block) | |
| Serialise (HeaderHash block) => Serialise (Point block) | |
| Condense (HeaderHash block) => Condense (Point block) Source # | |
| ShowProxy block => ShowProxy (Point block :: Type) | |
| type Rep (Point block) | |
Defined in Ouroboros.Network.Block type Rep (Point block) = D1 ('MetaData "Point" "Ouroboros.Network.Block" "ouroboros-network-0.1.0.0-DgIBwCUrGXaLitNwqCfIcM" 'True) (C1 ('MetaCons "Point" 'PrefixI 'True) (S1 ('MetaSel ('Just "getPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (WithOrigin (Block SlotNo (HeaderHash block)))))) | |
pointSlot :: Point block -> WithOrigin SlotNo #
class (Eq (HeaderHash b), Ord (HeaderHash b), Show (HeaderHash b), Typeable (HeaderHash b), NoThunks (HeaderHash b)) => StandardHash b #
Instances
| StandardHash b => StandardHash (HeaderFields b) | |
Defined in Ouroboros.Network.Block | |
| StandardHash block => StandardHash (Serialised block) | |
Defined in Ouroboros.Network.Block | |
| HasHeader blk => StandardHash (Header blk) Source # | |
Defined in Ouroboros.Consensus.Block.Abstract | |
| StandardHash blk => StandardHash (SerialisedHeader blk) Source # | |
Defined in Ouroboros.Consensus.Storage.Serialisation | |
| CanHardFork xs => StandardHash (HardForkBlock xs) Source # | |
| StandardHash blk => StandardHash (WithPoint blk b) Source # | |
Defined in Ouroboros.Consensus.Storage.ChainDB.API | |
| StandardHash m => StandardHash (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
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
| Bounded BlockNo | |
| Enum BlockNo | |
| Eq BlockNo | |
| Num BlockNo | |
| Ord BlockNo | |
Defined in Cardano.Slotting.Block | |
| Show BlockNo | |
| Generic BlockNo | |
| ToCBOR BlockNo | |
| FromCBOR BlockNo | |
| NoThunks BlockNo | |
| Serialise BlockNo | |
| Condense BlockNo Source # | |
| type Rep BlockNo | |
Defined in Cardano.Slotting.Block | |
An epoch, i.e. the number of the epoch.
Instances
| Enum EpochNo | |
| Eq EpochNo | |
| Num EpochNo | |
| Ord EpochNo | |
Defined in Cardano.Slotting.Slot | |
| Show EpochNo | |
| Generic EpochNo | |
| ToJSON EpochNo | |
| FromJSON EpochNo | |
| ToCBOR EpochNo | |
| FromCBOR EpochNo | |
| NoThunks EpochNo | |
| Serialise EpochNo | |
| Condense EpochNo Source # | |
| type Rep EpochNo | |
Defined in Cardano.Slotting.Slot | |
Constructors
| EpochSize | |
Fields | |
Instances
fromWithOrigin :: t -> WithOrigin t -> t Source #
The 0-based index for the Ourboros time slot.
Instances
| Bounded SlotNo | |
| Enum SlotNo | |
Defined in Cardano.Slotting.Slot | |
| Eq SlotNo | |
| Num SlotNo | |
| Ord SlotNo | |
| Show SlotNo | |
| Generic SlotNo | |
| NFData SlotNo | |
Defined in Cardano.Slotting.Slot | |
| ToJSON SlotNo | |
| FromJSON SlotNo | |
| ToCBOR SlotNo | |
| FromCBOR SlotNo | |
| NoThunks SlotNo | |
| Serialise SlotNo | |
| Condense SlotNo Source # | |
| type Rep SlotNo | |
Defined in Cardano.Slotting.Slot | |
withOrigin :: b -> (t -> b) -> WithOrigin t -> b Source #
withOriginFromMaybe :: Maybe t -> WithOrigin t Source #
data WithOrigin t Source #
Constructors
| Origin |
Bundled Patterns
| pattern NotOrigin :: t -> WithOrigin t | Custom pattern for This avoids clashing with our (extensive) use of |
Instances
withOriginToMaybe :: WithOrigin t -> Maybe t Source #