babe

package
v0.0.2-rc-2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Only allow primary slots.
	PrimarySlots sc.U8 = iota
	// Allow primary and secondary plain slots.
	PrimaryAndSecondaryPlainSlots
	// Allow primary and secondary VRF slots.
	PrimaryAndSecondaryVRFSlots
)

Types of allowed slots.

View Source
const RandomnessLength = 32

VRF output length for per-slot randomness.

Variables

View Source
var (
	ErrInvalidAllowedSlots = errors.New("invalid 'AllowedSlots' type")
)

Functions

This section is empty.

Types

type AllowedSlots

type AllowedSlots struct {
	sc.VaryingData
}

func DecodeAllowedSlots

func DecodeAllowedSlots(buffer *bytes.Buffer) (AllowedSlots, error)

func NewPrimaryAndSecondaryPlainSlots

func NewPrimaryAndSecondaryPlainSlots() AllowedSlots

func NewPrimaryAndSecondaryVRFSlots

func NewPrimaryAndSecondaryVRFSlots() AllowedSlots

func NewPrimarySlots

func NewPrimarySlots() AllowedSlots

func (AllowedSlots) String

func (a AllowedSlots) String() string

type Authority

type Authority struct {
	Key    AuthorityId
	Weight BabeAuthorityWeight
}

func DecodeAuthority

func DecodeAuthority(buffer *bytes.Buffer) (Authority, error)

func (Authority) Bytes

func (a Authority) Bytes() []byte

func (Authority) Encode

func (a Authority) Encode(buffer *bytes.Buffer) error

type AuthorityId

type AuthorityId = primitives.Sr25519PublicKey

A Babe authority identifier. Necessarily equivalent to the schnorrkel public key used in the main Babe module. If that ever changes, then this must, too.

type AuthorityIndex

type AuthorityIndex = sc.U32

type BabeAuthorityWeight

type BabeAuthorityWeight = sc.U64

The weight of an authority. We use a unique name for the weight to avoid conflicts with other `Weight` types, since the metadata isn't able to disambiguate.

type Configuration

type Configuration struct {
	// The slot duration in milliseconds for BABE. Currently, only
	// the value provided by this type at genesis will be used.
	//
	// Dynamic slot duration may be supported in the future.
	SlotDuration sc.U64

	// The duration of epochs in slots.
	EpochLength sc.U64

	// A constant value that is used in the threshold calculation formula.
	// In the threshold formula calculation, `1 - c` represents the probability
	// of a slot being empty.
	C primitives.RationalValue

	// The authorities
	Authorities sc.Sequence[Authority]

	// The randomness
	Randomness Randomness

	// Type of allowed slots.
	AllowedSlots AllowedSlots
}

Configuration data used by the BABE consensus engine.

func DecodeConfiguration

func DecodeConfiguration(buffer *bytes.Buffer) (Configuration, error)

func (Configuration) Bytes

func (c Configuration) Bytes() []byte

func (Configuration) Encode

func (c Configuration) Encode(buffer *bytes.Buffer) error

type Epoch

type Epoch struct {
	// The epoch index.
	EpochIndex sc.U64
	// The starting slot of the epoch.
	StartSlot Slot
	// The duration of this epoch.
	Duration sc.U64
	// The authorities and their weights.
	Authorities sc.Sequence[Authority]
	// Randomness for this epoch.
	Randomness Randomness
	// Configuration of the epoch.
	Config EpochConfiguration
}

BABE epoch information

func DecodeEpoch

func DecodeEpoch(buffer *bytes.Buffer) (Epoch, error)

func (Epoch) Bytes

func (e Epoch) Bytes() []byte

func (Epoch) Encode

func (e Epoch) Encode(buffer *bytes.Buffer) error

type EpochConfiguration

type EpochConfiguration struct {
	// A constant value that is used in the threshold calculation formula.
	// In the threshold formula calculation, `1 - c` represents the probability
	// of a slot being empty.
	C primitives.RationalValue

	// Whether this chain should run with secondary slots, which are assigned
	// in round-robin manner.
	AllowedSlots AllowedSlots
}

Configuration data used by the BABE consensus engine that may change with epochs.

func DecodeEpochConfiguration

func DecodeEpochConfiguration(buffer *bytes.Buffer) (EpochConfiguration, error)

func (EpochConfiguration) Bytes

func (c EpochConfiguration) Bytes() []byte

func (EpochConfiguration) Encode

func (c EpochConfiguration) Encode(buffer *bytes.Buffer) error

type EpochStartBlocks

type EpochStartBlocks struct {
	Previous sc.U64
	Current  sc.U64
}

func DecodeEpochStartBlocks

func DecodeEpochStartBlocks(buffer *bytes.Buffer) (EpochStartBlocks, error)

func (EpochStartBlocks) Bytes

func (e EpochStartBlocks) Bytes() []byte

func (EpochStartBlocks) Encode

func (e EpochStartBlocks) Encode(buffer *bytes.Buffer) error

type Randomness

type Randomness = sc.FixedSequence[sc.U8]

Randomness type required by BABE operations.

func NewRandomness

func NewRandomness() Randomness

type SessionIndex

type SessionIndex = sc.U32

type SkippedEpoch

type SkippedEpoch struct {
	sc.U64
	SessionIndex
}

func (SkippedEpoch) Bytes

func (se SkippedEpoch) Bytes() []byte

func (SkippedEpoch) Encode

func (se SkippedEpoch) Encode(buffer *bytes.Buffer) error

type Slot

type Slot = sc.U64

Jump to

Keyboard shortcuts

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