types

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2021 License: LGPL-3.0 Imports: 12 Imported by: 2

Documentation

Overview

Copyright 2020 ChainSafe Systems (ON) Corp. This file is part of gossamer.

The gossamer library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The gossamer library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the gossamer library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 ChainSafe Systems (ON) Corp. This file is part of gossamer.

The gossamer library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The gossamer library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the gossamer library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	// NoNetworkRole runs a node without networking
	NoNetworkRole = byte(0)
	// FullNodeRole runs a full node
	FullNodeRole = byte(1)
	// LightClientRole runs a light client
	LightClientRole = byte(2)
	// AuthorityRole runs the node as a block-producing and finalizing node
	AuthorityRole = byte(4)
)
View Source
const RandomnessLength = 32

RandomnessLength is the length of the epoch randomness (32 bytes)

Variables

View Source
var (
	BabePrimaryPreDigestType        = byte(1)
	BabeSecondaryPlainPreDigestType = byte(2)
	BabeSecondaryVRFPreDigestType   = byte(3)
)

nolint

View Source
var (
	GrandpaScheduledChangeType = byte(1)
	GrandpaForcedChangeType    = byte(2)
	GrandpaOnDisabledType      = byte(3)
	GrandpaPauseType           = byte(4)
	GrandpaResumeType          = byte(5)
)

The follow are the consensus digest types for grandpa

View Source
var (
	NextEpochDataType  = byte(1)
	BABEOnDisabledType = byte(2)
	NextConfigDataType = byte(3)
)

The follow are the consensus digest types for BABE

View Source
var (
	Timstap0 = []byte("timstap0")
	Babeslot = []byte("babeslot")
	Finalnum = []byte("finalnum")
	Uncles00 = []byte("uncles00")
)

nolint

View Source
var BabeEngineID = ConsensusEngineID{'B', 'A', 'B', 'E'}

BabeEngineID is the hard-coded babe ID

View Source
var ChangesTrieRootDigestType = byte(2)

ChangesTrieRootDigestType is the byte representation of ChangesTrieRootDigest

View Source
var ConsensusDigestType = byte(4)

ConsensusDigestType is the byte representation of ConsensusDigest

View Source
var GrandpaEngineID = ConsensusEngineID{'F', 'R', 'N', 'K'}

GrandpaEngineID is the hard-coded grandpa ID

View Source
var PreRuntimeDigestType = byte(6)

PreRuntimeDigestType is the byte representation of PreRuntimeDigest

View Source
var SealDigestType = byte(5)

SealDigestType is the byte representation of SealDigest

Functions

func EncodeBlockDataArray

func EncodeBlockDataArray(bds []*BlockData) ([]byte, error)

EncodeBlockDataArray encodes an array of BlockData using SCALE

func ExtrinsicsArrayToBytesArray

func ExtrinsicsArrayToBytesArray(exts []Extrinsic) [][]byte

ExtrinsicsArrayToBytesArray converts an array of extrinsics into an array of byte arrays

func GetSlotFromHeader added in v0.3.0

func GetSlotFromHeader(header *Header) (uint64, error)

GetSlotFromHeader returns the BABE slot from the given header

Types

type AccountInfo added in v0.3.0

type AccountInfo struct {
	// The number of transactions this account has sent.
	Nonce uint32
	// The number of other modules that currently depend on this account's existence. The account
	// cannot be reaped until this is zero.
	RefCount uint32
	// The additional data that belongs to this account. Used to store the balance(s) in a lot of chains.
	Data struct {
		Free       common.Uint128
		Reserved   common.Uint128
		MiscFrozen common.Uint128
		FreeFrozen common.Uint128
	}
}

AccountInfo Information of an account.

type Authority added in v0.2.0

type Authority struct {
	Key    crypto.PublicKey
	Weight uint64
}

Authority struct to hold authority data

func BABEAuthorityRawToAuthority added in v0.2.0

func BABEAuthorityRawToAuthority(adr []*AuthorityRaw) ([]*Authority, error)

BABEAuthorityRawToAuthority turns a slice of BABE AuthorityRaw into a slice of Authority

func GrandpaAuthoritiesRawToAuthorities added in v0.3.0

func GrandpaAuthoritiesRawToAuthorities(adr []*GrandpaAuthoritiesRaw) ([]*Authority, error)

GrandpaAuthoritiesRawToAuthorities turns a slice of GrandpaAuthoritiesRaw into a slice of Authority

func NewAuthority added in v0.2.0

func NewAuthority(pub crypto.PublicKey, weight uint64) *Authority

NewAuthority function to create Authority object

func (*Authority) Decode added in v0.3.0

func (a *Authority) Decode(r io.Reader) error

Decode sets the

func (*Authority) DecodeSr25519 added in v0.2.0

func (a *Authority) DecodeSr25519(r io.Reader) error

DecodeSr25519 sets the Authority to the SCALE decoded input for Authority containing SR25519 Keys.

func (*Authority) Encode added in v0.2.0

func (a *Authority) Encode() ([]byte, error)

Encode returns the SCALE encoding of the BABEAuthorities.

func (*Authority) FromRawEd25519 added in v0.2.0

func (a *Authority) FromRawEd25519(raw *GrandpaAuthoritiesRaw) error

FromRawEd25519 sets the Authority given GrandpaAuthoritiesRaw. It converts the byte representations of the authority public keys into a ed25519.PublicKey.

func (*Authority) FromRawSr25519 added in v0.2.0

func (a *Authority) FromRawSr25519(raw *AuthorityRaw) error

FromRawSr25519 sets the Authority given AuthorityRaw. It converts the byte representations of the authority public keys into a sr25519.PublicKey.

func (*Authority) ToRaw added in v0.2.0

func (a *Authority) ToRaw() *AuthorityRaw

ToRaw returns the BABEAuthorities as BABEAuthoritiesRaw. It encodes the authority public keys.

type AuthorityRaw added in v0.2.0

type AuthorityRaw struct {
	Key    [sr25519.PublicKeyLength]byte
	Weight uint64
}

AuthorityRaw struct to hold raw authority data

func AuthoritiesToRaw added in v0.3.0

func AuthoritiesToRaw(auths []*Authority) []*AuthorityRaw

AuthoritiesToRaw converts an array of Authority in an array of AuthorityRaw

func (*AuthorityRaw) Decode added in v0.2.0

func (a *AuthorityRaw) Decode(r io.Reader) (*AuthorityRaw, error)

Decode will decode the Reader into a AuthorityRaw

type BABEOnDisabled added in v0.3.0

type BABEOnDisabled struct {
	ID uint32
}

BABEOnDisabled represents a GRANDPA authority being disabled

func (*BABEOnDisabled) Encode added in v0.3.0

func (od *BABEOnDisabled) Encode() ([]byte, error)

Encode returns a SCALE encoded BABEOnDisabled with first type byte

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 []*AuthorityRaw
	Randomness         [32]byte
	SecondarySlots     byte
}

BabeConfiguration contains the genesis data for BABE see: https://github.com/paritytech/substrate/blob/426c26b8bddfcdbaf8d29f45b128e0864b57de1c/core/consensus/babe/primitives/src/lib.rs#L132

type BabePreRuntimeDigest added in v0.3.0

type BabePreRuntimeDigest interface {
	Type() byte
	Encode() []byte
	Decode(r io.Reader) error
	AuthorityIndex() uint32
	SlotNumber() uint64
}

BabePreRuntimeDigest must be implemented by all BABE pre-runtime digest types

func DecodeBabePreDigest added in v0.3.0

func DecodeBabePreDigest(r io.Reader) (BabePreRuntimeDigest, error)

DecodeBabePreDigest decodes the input into a BabePreRuntimeDigest

type BabePrimaryPreDigest added in v0.3.0

type BabePrimaryPreDigest struct {
	// contains filtered or unexported fields
}

BabePrimaryPreDigest as defined in Polkadot RE Spec, definition 5.10 in section 5.1.4

func NewBabePrimaryPreDigest added in v0.3.0

func NewBabePrimaryPreDigest(authorityIndex uint32, slotNumber uint64, vrfOutput [sr25519.VrfOutputLength]byte, vrfProof [sr25519.VrfProofLength]byte) *BabePrimaryPreDigest

NewBabePrimaryPreDigest returns a new BabePrimaryPreDigest

func (*BabePrimaryPreDigest) AuthorityIndex added in v0.3.0

func (d *BabePrimaryPreDigest) AuthorityIndex() uint32

AuthorityIndex returns the digest's authority index

func (*BabePrimaryPreDigest) Decode added in v0.3.0

func (d *BabePrimaryPreDigest) Decode(r io.Reader) (err error)

Decode performs SCALE decoding of an encoded BabePrimaryPreDigest, assuming type byte is removed

func (*BabePrimaryPreDigest) Encode added in v0.3.0

func (d *BabePrimaryPreDigest) Encode() []byte

Encode performs SCALE encoding of a BABEPrimaryPreDigest

func (*BabePrimaryPreDigest) SlotNumber added in v0.3.0

func (d *BabePrimaryPreDigest) SlotNumber() uint64

SlotNumber returns the digest's slot number

func (*BabePrimaryPreDigest) ToPreRuntimeDigest added in v0.3.1

func (d *BabePrimaryPreDigest) ToPreRuntimeDigest() *PreRuntimeDigest

ToPreRuntimeDigest returns the BabePrimaryPreDigest as a PreRuntimeDigest

func (*BabePrimaryPreDigest) Type added in v0.3.0

func (d *BabePrimaryPreDigest) Type() byte

Type returns BabePrimaryPreDigestType

func (*BabePrimaryPreDigest) VrfOutput added in v0.3.0

VrfOutput returns the digest's VRF output

func (*BabePrimaryPreDigest) VrfProof added in v0.3.0

VrfProof returns the digest's VRF proof

type BabeSecondaryPlainPreDigest added in v0.3.0

type BabeSecondaryPlainPreDigest struct {
	// contains filtered or unexported fields
}

BabeSecondaryPlainPreDigest is included in a block built by a secondary slot authorized producer

func NewBabeSecondaryPlainPreDigest added in v0.3.0

func NewBabeSecondaryPlainPreDigest(authorityIndex uint32, slotNumber uint64) *BabeSecondaryPlainPreDigest

NewBabeSecondaryPlainPreDigest returns a new BabeSecondaryPlainPreDigest

func (*BabeSecondaryPlainPreDigest) AuthorityIndex added in v0.3.0

func (d *BabeSecondaryPlainPreDigest) AuthorityIndex() uint32

AuthorityIndex returns the digest's authority index

func (*BabeSecondaryPlainPreDigest) Decode added in v0.3.0

func (d *BabeSecondaryPlainPreDigest) Decode(r io.Reader) (err error)

Decode performs SCALE decoding of an encoded BabeSecondaryPlainPreDigest

func (*BabeSecondaryPlainPreDigest) Encode added in v0.3.0

func (d *BabeSecondaryPlainPreDigest) Encode() []byte

Encode performs SCALE encoding of a BabeSecondaryPlainPreDigest

func (*BabeSecondaryPlainPreDigest) SlotNumber added in v0.3.0

func (d *BabeSecondaryPlainPreDigest) SlotNumber() uint64

SlotNumber returns the digest's slot number

func (*BabeSecondaryPlainPreDigest) ToPreRuntimeDigest added in v0.3.2

func (d *BabeSecondaryPlainPreDigest) ToPreRuntimeDigest() *PreRuntimeDigest

ToPreRuntimeDigest returns the BabePrimaryPreDigest as a PreRuntimeDigest

func (*BabeSecondaryPlainPreDigest) Type added in v0.3.0

Type returns BabeSecondaryPlainPreDigestType

type BabeSecondaryVRFPreDigest added in v0.3.0

type BabeSecondaryVRFPreDigest struct {
	// contains filtered or unexported fields
}

BabeSecondaryVRFPreDigest is included in a block built by a secondary slot authorized producer

func NewBabeSecondaryVRFPreDigest added in v0.3.0

func NewBabeSecondaryVRFPreDigest(authorityIndex uint32, slotNumber uint64, vrfOutput [sr25519.VrfOutputLength]byte, vrfProof [sr25519.VrfProofLength]byte) *BabeSecondaryVRFPreDigest

NewBabeSecondaryVRFPreDigest returns a new NewBabeSecondaryVRFPreDigest

func (*BabeSecondaryVRFPreDigest) AuthorityIndex added in v0.3.0

func (d *BabeSecondaryVRFPreDigest) AuthorityIndex() uint32

AuthorityIndex returns the digest's authority index

func (*BabeSecondaryVRFPreDigest) Decode added in v0.3.0

func (d *BabeSecondaryVRFPreDigest) Decode(r io.Reader) (err error)

Decode performs SCALE decoding of an encoded BabeSecondaryVRFPreDigest, assuming type byte is removed

func (*BabeSecondaryVRFPreDigest) Encode added in v0.3.0

func (d *BabeSecondaryVRFPreDigest) Encode() []byte

Encode performs SCALE encoding of a BABEPrimaryPreDigest

func (*BabeSecondaryVRFPreDigest) SlotNumber added in v0.3.0

func (d *BabeSecondaryVRFPreDigest) SlotNumber() uint64

SlotNumber returns the digest's slot number

func (*BabeSecondaryVRFPreDigest) Type added in v0.3.0

func (d *BabeSecondaryVRFPreDigest) Type() byte

Type returns BabeSecondaryVRFPreDigestType

func (*BabeSecondaryVRFPreDigest) VrfOutput added in v0.3.0

VrfOutput returns the digest's VRF output

func (*BabeSecondaryVRFPreDigest) VrfProof added in v0.3.0

VrfProof returns the digest's VRF proof

type Block

type Block struct {
	Header *Header
	Body   *Body
}

Block defines a state block

func NewBlock

func NewBlock(header *Header, body *Body) *Block

NewBlock returns a new Block

func NewEmptyBlock

func NewEmptyBlock() *Block

NewEmptyBlock returns a new Block with an initialized but empty Header and Body

func (*Block) Decode

func (b *Block) Decode(r io.Reader) error

Decode decodes the SCALE encoded input into this block

func (*Block) DeepCopy

func (b *Block) DeepCopy() *Block

DeepCopy returns a copy of the block

func (*Block) Encode

func (b *Block) Encode() ([]byte, error)

Encode returns the SCALE encoding of a block

func (*Block) MustEncode added in v0.2.0

func (b *Block) MustEncode() []byte

MustEncode returns the SCALE encoded block and panics if it fails to encode

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

func DecodeBlockDataArray(r io.Reader) ([]*BlockData, error)

DecodeBlockDataArray decodes a SCALE encoded BlockData array

func (*BlockData) Decode

func (bd *BlockData) Decode(r io.Reader) error

Decode decodes the SCALE encoded input to BlockData

func (*BlockData) Encode

func (bd *BlockData) Encode() ([]byte, error)

Encode performs SCALE encoding of the BlockData

func (*BlockData) Number added in v0.3.0

func (bd *BlockData) Number() *big.Int

Number returns the BlockNumber of the BlockData's header, nil if it doesn't exist

func (*BlockData) String added in v0.3.0

func (bd *BlockData) String() string

type Body

type Body []byte

Body is the encoded extrinsics inside a state block

func NewBody

func NewBody(b []byte) *Body

NewBody returns a Body from a byte array

func NewBodyFromBytes added in v0.3.0

func NewBodyFromBytes(exts [][]byte) (*Body, error)

NewBodyFromBytes returns a new Body from a slice of byte slices

func NewBodyFromEncodedBytes added in v0.3.0

func NewBodyFromEncodedBytes(exts [][]byte) (*Body, error)

NewBodyFromEncodedBytes returns a new Body from a slice of byte slices that are SCALE encoded extrinsics

func NewBodyFromExtrinsicStrings

func NewBodyFromExtrinsicStrings(ss []string) (*Body, error)

NewBodyFromExtrinsicStrings creates a block body given an array of hex-encoded 0x-prefixed strings.

func NewBodyFromExtrinsics

func NewBodyFromExtrinsics(exts []Extrinsic) (*Body, error)

NewBodyFromExtrinsics creates a block body given an array of extrinsics.

func NewBodyFromOptional

func NewBodyFromOptional(ob *optional.Body) (*Body, error)

NewBodyFromOptional returns a Body given an optional.Body. If the optional.Body is None, an error is returned.

func (*Body) AsEncodedExtrinsics added in v0.3.0

func (b *Body) AsEncodedExtrinsics() ([]Extrinsic, error)

AsEncodedExtrinsics decodes the body into an array of SCALE encoded extrinsics

func (*Body) AsExtrinsics

func (b *Body) AsExtrinsics() ([]Extrinsic, error)

AsExtrinsics decodes the body into an array of extrinsics

func (*Body) AsOptional

func (b *Body) AsOptional() *optional.Body

AsOptional returns the Body as an optional.Body

type ChangesTrieRootDigest

type ChangesTrieRootDigest struct {
	Hash common.Hash
}

ChangesTrieRootDigest contains the root of the changes trie at a given block, if the runtime supports it.

func (*ChangesTrieRootDigest) Decode

func (d *ChangesTrieRootDigest) Decode(r io.Reader) error

Decode will decode into ChangesTrieRootDigest Hash

func (*ChangesTrieRootDigest) Encode

func (d *ChangesTrieRootDigest) Encode() ([]byte, error)

Encode will encode the ChangesTrieRootDigestType into byte array

func (*ChangesTrieRootDigest) String added in v0.3.0

func (d *ChangesTrieRootDigest) String() string

String returns the digest as a string

func (*ChangesTrieRootDigest) Type

func (d *ChangesTrieRootDigest) Type() byte

Type returns the type

type ConfigData added in v0.3.0

type ConfigData struct {
	C1             uint64
	C2             uint64
	SecondarySlots byte
}

ConfigData represents a BABE configuration update

type ConsensusDigest

type ConsensusDigest struct {
	ConsensusEngineID ConsensusEngineID
	Data              []byte
}

ConsensusDigest contains messages from the runtime to the consensus engine.

func (*ConsensusDigest) DataType added in v0.2.0

func (d *ConsensusDigest) DataType() byte

DataType returns the data type of the runtime-to-consensus engine message

func (*ConsensusDigest) Decode

func (d *ConsensusDigest) Decode(r io.Reader) error

Decode will decode into ConsensusEngineID and Data

func (*ConsensusDigest) Encode

func (d *ConsensusDigest) Encode() ([]byte, error)

Encode will encode ConsensusDigest ConsensusEngineID and Data

func (*ConsensusDigest) String added in v0.3.0

func (d *ConsensusDigest) String() string

String returns the digest as a string

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 Digest added in v0.3.0

type Digest []DigestItem

Digest represents the block digest. It consists of digest items.

func DecodeDigest added in v0.3.0

func DecodeDigest(r io.Reader) (Digest, error)

DecodeDigest decodes the input into a Digest

func NewEmptyDigest added in v0.3.0

func NewEmptyDigest() Digest

NewEmptyDigest returns an empty digest

func (*Digest) Decode added in v0.3.0

func (d *Digest) Decode(r io.Reader) error

Decode decodes a SCALE encoded digest and appends it to the given Digest

func (*Digest) Encode added in v0.3.0

func (d *Digest) Encode() ([]byte, error)

Encode returns the SCALE encoded digest

type DigestItem

type DigestItem interface {
	String() string
	Type() byte
	Encode() ([]byte, error)
	Decode(io.Reader) 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(r io.Reader) (DigestItem, error)

DecodeDigestItem will decode byte array to DigestItem

type EpochData added in v0.3.0

type EpochData struct {
	Authorities []*Authority
	Randomness  [RandomnessLength]byte
}

EpochData is the data provided for a BABE epoch

func (*EpochData) ToEpochDataRaw added in v0.3.0

func (d *EpochData) ToEpochDataRaw() *EpochDataRaw

ToEpochDataRaw returns the EpochData as an EpochDataRaw, converting the Authority to AuthorityRaw

type EpochDataRaw added in v0.3.0

type EpochDataRaw struct {
	Authorities []*AuthorityRaw
	Randomness  [RandomnessLength]byte
}

EpochDataRaw is the data provided for an epoch, with Authority as AuthorityRaw

func (*EpochDataRaw) ToEpochData added in v0.3.0

func (d *EpochDataRaw) ToEpochData() (*EpochData, error)

ToEpochData returns the EpochDataRaw as EpochData

type Extrinsic

type Extrinsic []byte

Extrinsic is a generic transaction whose format is verified in the runtime

func BytesArrayToExtrinsics

func BytesArrayToExtrinsics(b [][]byte) []Extrinsic

BytesArrayToExtrinsics converts an array of byte arrays into an array of extrinsics

func NewExtrinsic

func NewExtrinsic(e []byte) Extrinsic

NewExtrinsic creates a new Extrinsic given a byte slice

func (Extrinsic) Hash

func (e Extrinsic) Hash() common.Hash

Hash returns the blake2b hash of the extrinsic

type GrandpaAuthoritiesRaw added in v0.3.0

type GrandpaAuthoritiesRaw struct {
	Key [ed25519.PublicKeyLength]byte
	ID  uint64
}

GrandpaAuthoritiesRaw represents a GRANDPA authority where their key is a byte array

func (*GrandpaAuthoritiesRaw) Decode added in v0.3.0

Decode will decode the Reader into a GrandpaAuthoritiesRaw

type GrandpaForcedChange added in v0.2.0

type GrandpaForcedChange struct {
	Auths []*GrandpaAuthoritiesRaw
	Delay uint32
}

GrandpaForcedChange represents a GRANDPA forced authority change

func (*GrandpaForcedChange) Encode added in v0.2.0

func (fc *GrandpaForcedChange) Encode() ([]byte, error)

Encode returns a SCALE encoded GrandpaForcedChange with first type byte

type GrandpaOnDisabled added in v0.3.0

type GrandpaOnDisabled struct {
	ID uint64
}

GrandpaOnDisabled represents a GRANDPA authority being disabled

func (*GrandpaOnDisabled) Encode added in v0.3.0

func (od *GrandpaOnDisabled) Encode() ([]byte, error)

Encode returns a SCALE encoded GrandpaOnDisabled with first type byte

type GrandpaPause added in v0.3.0

type GrandpaPause struct {
	Delay uint32
}

GrandpaPause represents an authority set pause

func (*GrandpaPause) Encode added in v0.3.0

func (p *GrandpaPause) Encode() ([]byte, error)

Encode returns a SCALE encoded GrandpaPause with first type byte

type GrandpaResume added in v0.3.0

type GrandpaResume struct {
	Delay uint32
}

GrandpaResume represents an authority set resume

func (*GrandpaResume) Encode added in v0.3.0

func (r *GrandpaResume) Encode() ([]byte, error)

Encode returns a SCALE encoded GrandpaResume with first type byte

type GrandpaScheduledChange added in v0.2.0

type GrandpaScheduledChange struct {
	Auths []*GrandpaAuthoritiesRaw
	Delay uint32
}

GrandpaScheduledChange represents a GRANDPA scheduled authority change

func (*GrandpaScheduledChange) Encode added in v0.2.0

func (sc *GrandpaScheduledChange) Encode() ([]byte, error)

Encode returns a SCALE encoded GrandpaScheduledChange with first type byte

type Header struct {
	ParentHash     common.Hash `json:"parentHash"`
	Number         *big.Int    `json:"number"`
	StateRoot      common.Hash `json:"stateRoot"`
	ExtrinsicsRoot common.Hash `json:"extrinsicsRoot"`
	Digest         Digest      `json:"digest"`
	// contains filtered or unexported fields
}

Header is a state block header

func NewEmptyHeader added in v0.3.0

func NewEmptyHeader() *Header

NewEmptyHeader returns a new header with all zero values

func NewHeader

func NewHeader(parentHash common.Hash, number *big.Int, stateRoot common.Hash, extrinsicsRoot common.Hash, digest []DigestItem) (*Header, error)

NewHeader creates a new block header and sets its hash field

func NewHeaderFromOptional

func NewHeaderFromOptional(oh *optional.Header) (*Header, error)

NewHeaderFromOptional returns a Header given an optional.Header. If the optional.Header is None, an error is returned.

func (*Header) AsOptional

func (bh *Header) AsOptional() *optional.Header

AsOptional returns the Header as an optional.Header

func (*Header) Decode

func (bh *Header) Decode(r io.Reader) (*Header, error)

Decode decodes the SCALE encoded input into this header

func (*Header) DeepCopy

func (bh *Header) DeepCopy() *Header

DeepCopy returns a deep copy of the header to prevent side effects down the road

func (*Header) Encode

func (bh *Header) Encode() ([]byte, error)

Encode returns the SCALE encoding of a header

func (*Header) Hash

func (bh *Header) Hash() common.Hash

Hash returns the hash of the block header If the internal hash field is nil, it hashes the block and sets the hash field. If hashing the header errors, this will panic.

func (*Header) MustEncode added in v0.2.0

func (bh *Header) MustEncode() []byte

MustEncode returns the SCALE encoded header and panics if it fails to encode

func (*Header) String

func (bh *Header) String() string

String returns the formatted header as a string

type InherentsData added in v0.2.0

type InherentsData struct {
	// contains filtered or unexported fields
}

InherentsData contains a mapping of inherent keys to values keys must be 8 bytes, values are a scale-encoded byte array

func NewInherentsData added in v0.2.0

func NewInherentsData() *InherentsData

NewInherentsData returns InherentsData

func (*InherentsData) Encode added in v0.2.0

func (d *InherentsData) Encode() ([]byte, error)

Encode will encode a given []byte using scale.Encode

func (*InherentsData) SetBigIntInherent added in v0.2.0

func (d *InherentsData) SetBigIntInherent(key []byte, data *big.Int) error

SetBigIntInherent set as a big.Int (compact int) inherent

func (*InherentsData) SetInt64Inherent added in v0.2.0

func (d *InherentsData) SetInt64Inherent(key []byte, data uint64) error

SetInt64Inherent set the Int64 scale.Encode for a given data

func (*InherentsData) String added in v0.2.0

func (d *InherentsData) String() string

type NextConfigData added in v0.3.0

type NextConfigData struct {
	C1             uint64
	C2             uint64
	SecondarySlots byte
}

NextConfigData is the digest that contains changes to the BABE configuration. It is potentially included in the first block of an epoch to describe the next epoch.

func (*NextConfigData) Encode added in v0.3.0

func (d *NextConfigData) Encode() ([]byte, error)

Encode returns a SCALE encoded NextConfigData with first type byte

func (*NextConfigData) ToConfigData added in v0.3.0

func (d *NextConfigData) ToConfigData() *ConfigData

ToConfigData returns the NextConfigData as ConfigData

type NextEpochData added in v0.3.0

type NextEpochData struct {
	Authorities []*AuthorityRaw
	Randomness  [RandomnessLength]byte
}

NextEpochData is the digest that contains the data for the upcoming BABE epoch. It is included in the first block of every epoch to describe the next epoch.

func (*NextEpochData) Encode added in v0.3.0

func (d *NextEpochData) Encode() ([]byte, error)

Encode returns a SCALE encoded NextEpochData with first type byte

func (*NextEpochData) ToEpochData added in v0.3.0

func (d *NextEpochData) ToEpochData() (*EpochData, error)

ToEpochData returns the NextEpochData as EpochData

type PreRuntimeDigest

type PreRuntimeDigest struct {
	ConsensusEngineID ConsensusEngineID
	Data              []byte
}

PreRuntimeDigest contains messages from the consensus engine to the runtime.

func NewBABEPreRuntimeDigest added in v0.3.0

func NewBABEPreRuntimeDigest(data []byte) *PreRuntimeDigest

NewBABEPreRuntimeDigest returns a PreRuntimeDigest with the BABE consensus ID

func (*PreRuntimeDigest) Decode

func (d *PreRuntimeDigest) Decode(r io.Reader) error

Decode will decode PreRuntimeDigest ConsensusEngineID and Data

func (*PreRuntimeDigest) Encode

func (d *PreRuntimeDigest) Encode() ([]byte, error)

Encode will encode PreRuntimeDigest ConsensusEngineID and Data

func (*PreRuntimeDigest) String added in v0.3.0

func (d *PreRuntimeDigest) String() string

String returns the digest as a string

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(r io.Reader) error

Decode will decode into SealDigest ConsensusEngineID and Data

func (*SealDigest) Encode

func (d *SealDigest) Encode() ([]byte, error)

Encode will encode SealDigest ConsensusEngineID and Data

func (*SealDigest) String added in v0.3.0

func (d *SealDigest) String() string

String returns the digest as a string

func (*SealDigest) Type

func (d *SealDigest) Type() byte

Type will return SealDigest type

type SystemInfo

type SystemInfo struct {
	SystemName    string
	SystemVersion string
}

SystemInfo struct to hold system related information

type TransactionSource added in v0.3.0

type TransactionSource uint8

TransactionSource represents source of Transaction

const (
	// TxnInBlock indicates transaction is already included in block.
	//
	// This means that we can't really tell where the transaction is coming from,
	// since it's already in the received block. Note that the custom validation logic
	// using either `Local` or `External` should most likely just allow `InBlock`
	// transactions as well.
	TxnInBlock TransactionSource = iota

	// TxnLocal indicates transaction is coming from a local source.
	//
	// This means that the transaction was produced internally by the node
	// (for instance an Off-Chain Worker, or an Off-Chain Call), as opposed
	// to being received over the network.
	TxnLocal

	// TxnExternal indicates transaction has been received externally.
	//
	// This means the transaction has been received from (usually) "untrusted" source,
	// for instance received over the network or RPC.
	TxnExternal
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL