Documentation ¶
Index ¶
- Variables
- func EncodeBlockDataArray(bds []*BlockData) ([]byte, error)
- func ExtrinsicsArrayToBytesArray(exts []Extrinsic) [][]byte
- type AuthorityData
- type AuthorityDataRaw
- type BabeConfiguration
- type BabeHeader
- type Block
- type BlockData
- type Body
- type ChangesTrieRootDigest
- type ConsensusDigest
- type ConsensusEngineID
- type DigestItem
- type Extrinsic
- type Header
- type PreRuntimeDigest
- type SealDigest
- type SystemInfo
Constants ¶
This section is empty.
Variables ¶
var BabeEngineID = ConsensusEngineID{'B', 'A', 'B', 'E'}
BabeEngineID is the hard-coded babe ID
var ChangesTrieRootDigestType = byte(2)
ChangesTrieRootDigestType is the byte representation of ChangesTrieRootDigest
var ConsensusDigestType = byte(4)
ConsensusDigestType is the byte representation of ConsensusDigest
var PreRuntimeDigestType = byte(6)
PreRuntimeDigestType is the byte representation of PreRuntimeDigest
var SealDigestType = byte(5)
SealDigestType is the byte representation of SealDigest
Functions ¶
func EncodeBlockDataArray ¶
EncodeBlockDataArray encodes an array of BlockData using SCALE
func ExtrinsicsArrayToBytesArray ¶
ExtrinsicsArrayToBytesArray converts an array of extrinsics into an array of byte arrays
Types ¶
type AuthorityData ¶
AuthorityData represents a BABE authority
func NewAuthorityData ¶
func NewAuthorityData(pub *sr25519.PublicKey, weight uint64) *AuthorityData
NewAuthorityData returns AuthorityData with the given id and weight
func (*AuthorityData) Decode ¶
func (a *AuthorityData) Decode(r io.Reader) error
Decode sets the AuthorityData to the SCALE decoded input.
func (*AuthorityData) Encode ¶
func (a *AuthorityData) Encode() []byte
Encode returns the SCALE encoding of the AuthorityData.
func (*AuthorityData) FromRaw ¶
func (a *AuthorityData) FromRaw(raw *AuthorityDataRaw) error
FromRaw sets the AuthorityData given AuthorityDataRaw. It converts the byte representations of the authority public keys into a sr25519.PublicKey.
func (*AuthorityData) ToRaw ¶
func (a *AuthorityData) ToRaw() *AuthorityDataRaw
ToRaw returns the AuthorityData as AuthorityDataRaw. It encodes the authority public keys.
type AuthorityDataRaw ¶
type AuthorityDataRaw struct { ID [sr25519.PublicKeyLength]byte Weight uint64 }
AuthorityDataRaw represents a BABE authority where their key is a byte array
func (*AuthorityDataRaw) Decode ¶
func (a *AuthorityDataRaw) Decode(r io.Reader) (*AuthorityDataRaw, error)
Decode will decode the Reader into a AuthorityDataRaw
type BabeConfiguration ¶
type BabeConfiguration struct { SlotDuration uint64 // milliseconds EpochLength uint64 // duration of epoch in slots C1 uint64 // (1-(c1/c2)) is the probability of a slot being empty C2 uint64 GenesisAuthorities []*AuthorityDataRaw Randomness byte // TODO: change to [RandomnessLength]byte when updating to new runtime SecondarySlots bool }
BabeConfiguration contains the genesis data for BABE see: https://github.com/paritytech/substrate/blob/426c26b8bddfcdbaf8d29f45b128e0864b57de1c/core/consensus/babe/primitives/src/lib.rs#L132
type BabeHeader ¶
type BabeHeader struct { VrfOutput [sr25519.VrfOutputLength]byte VrfProof [sr25519.VrfProofLength]byte BlockProducerIndex uint64 SlotNumber uint64 }
BabeHeader as defined in Polkadot RE Spec, definition 5.10 in section 5.1.4
func (*BabeHeader) Decode ¶
func (bh *BabeHeader) Decode(in []byte) error
Decode performs SCALE decoding of an encoded BabeHeader
func (*BabeHeader) Encode ¶
func (bh *BabeHeader) Encode() []byte
Encode performs SCALE encoding of a BabeHeader
type Block ¶
Block defines a state block
func NewEmptyBlock ¶
func NewEmptyBlock() *Block
NewEmptyBlock returns a new Block with an initialized but empty Header and Body
type BlockData ¶
type BlockData struct { Hash common.Hash Header *optional.Header Body *optional.Body Receipt *optional.Bytes MessageQueue *optional.Bytes Justification *optional.Bytes }
BlockData is stored within the BlockDB
func DecodeBlockDataArray ¶
DecodeBlockDataArray decodes a SCALE encoded BlockData array
type Body ¶
type Body []byte
Body is the encoded extrinsics inside a state block
func NewBodyFromExtrinsicStrings ¶
NewBodyFromExtrinsicStrings creates a block body given an array of hex-encoded 0x-prefixed strings.
func NewBodyFromExtrinsics ¶
NewBodyFromExtrinsics creates a block body given an array of extrinsics.
func NewBodyFromOptional ¶
NewBodyFromOptional returns a Body given an optional.Body. If the optional.Body is None, an error is returned.
func (*Body) AsExtrinsics ¶
AsExtrinsics decodes the body into an array of extrinsics
func (*Body) AsOptional ¶
AsOptional returns the Body as an optional.Body
type ChangesTrieRootDigest ¶
ChangesTrieRootDigest contains the root of the changes trie at a given block, if the runtime supports it.
func (*ChangesTrieRootDigest) Decode ¶
func (d *ChangesTrieRootDigest) Decode(in []byte) error
Decode will decode into ChangesTrieRootDigest Hash
func (*ChangesTrieRootDigest) Encode ¶
func (d *ChangesTrieRootDigest) Encode() []byte
Encode will encode the ChangesTrieRootDigestType into byte array
func (*ChangesTrieRootDigest) Type ¶
func (d *ChangesTrieRootDigest) Type() byte
Type returns the type
type ConsensusDigest ¶
type ConsensusDigest struct { ConsensusEngineID ConsensusEngineID Data []byte }
ConsensusDigest contains messages from the runtime to the consensus engine.
func (*ConsensusDigest) Decode ¶
func (d *ConsensusDigest) Decode(in []byte) error
Decode will decode into ConsensusEngineID and Data
func (*ConsensusDigest) Encode ¶
func (d *ConsensusDigest) Encode() []byte
Encode will encode ConsensusDigest ConsensusEngineID and Data
func (*ConsensusDigest) Type ¶
func (d *ConsensusDigest) Type() byte
Type returns the ConsensusDigest type
type ConsensusEngineID ¶
type ConsensusEngineID [4]byte
ConsensusEngineID is a 4-character identifier of the consensus engine that produced the digest.
func NewConsensusEngineID ¶
func NewConsensusEngineID(in []byte) (res ConsensusEngineID)
NewConsensusEngineID casts a byte array to ConsensusEngineID if the input is longer than 4 bytes, it takes the first 4 bytes
func (ConsensusEngineID) ToBytes ¶
func (h ConsensusEngineID) ToBytes() []byte
ToBytes turns ConsensusEngineID to a byte array
type DigestItem ¶
type DigestItem interface { Type() byte Encode() []byte Decode([]byte) error // Decode assumes the type byte (first byte) has been removed from the encoding. }
DigestItem can be of one of four types of digest: ChangesTrieRootDigest, PreRuntimeDigest, ConsensusDigest, or SealDigest. see https://github.com/paritytech/substrate/blob/f548309478da3935f72567c2abc2eceec3978e9f/primitives/runtime/src/generic/digest.rs#L77
func DecodeDigestItem ¶
func DecodeDigestItem(in []byte) (DigestItem, error)
DecodeDigestItem will decode byte array to DigestItem
type Extrinsic ¶
type Extrinsic []byte
Extrinsic is a generic transaction whose format is verified in the runtime
func BytesArrayToExtrinsics ¶
BytesArrayToExtrinsics converts an array of byte arrays into an array of extrinsics
func NewExtrinsic ¶
NewExtrinsic creates a new Extrinsic given a byte slice
type Header ¶
type Header struct { ParentHash common.Hash `json:"parentHash"` Number *big.Int `json:"number"` StateRoot common.Hash `json:"stateRoot"` ExtrinsicsRoot common.Hash `json:"extrinsicsRoot"` Digest [][]byte `json:"digest"` // contains filtered or unexported fields }
Header is a state block header
func NewHeader ¶
func NewHeader(parentHash common.Hash, number *big.Int, stateRoot common.Hash, extrinsicsRoot common.Hash, digest [][]byte) (*Header, error)
NewHeader creates a new block header and sets its hash field
func NewHeaderFromOptional ¶
NewHeaderFromOptional returns a Header given an optional.Header. If the optional.Header is None, an error is returned.
func (*Header) AsOptional ¶
AsOptional returns the Header as an optional.Header
func (*Header) DeepCopy ¶
DeepCopy returns a deep copy of the header to prevent side effects down the road
type PreRuntimeDigest ¶
type PreRuntimeDigest struct { ConsensusEngineID ConsensusEngineID Data []byte }
PreRuntimeDigest contains messages from the consensus engine to the runtime.
func (*PreRuntimeDigest) Decode ¶
func (d *PreRuntimeDigest) Decode(in []byte) error
Decode will decode PreRuntimeDigest ConsensusEngineID and Data
func (*PreRuntimeDigest) Encode ¶
func (d *PreRuntimeDigest) Encode() []byte
Encode will encode PreRuntimeDigest ConsensusEngineID and Data
func (*PreRuntimeDigest) Type ¶
func (d *PreRuntimeDigest) Type() byte
Type will return PreRuntimeDigestType
type SealDigest ¶
type SealDigest struct { ConsensusEngineID ConsensusEngineID Data []byte }
SealDigest contains the seal or signature. This is only used by native code.
func (*SealDigest) Decode ¶
func (d *SealDigest) Decode(in []byte) error
Decode will decode into SealDigest ConsensusEngineID and Data
func (*SealDigest) Encode ¶
func (d *SealDigest) Encode() []byte
Encode will encode SealDigest ConsensusEngineID and Data