controller

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InstanceContainerDefaultCapacity is the default capacity for InstanceContainer.
	InstanceContainerDefaultCapacity int = 2

	// InstanceContainerTestCapacity is the capacity for InstanceContainer used in tests.
	InstanceContainerTestCapacity int = 1024
)

Variables

This section is empty.

Functions

func IsDecidedMsg

func IsDecidedMsg(share *spectypes.Share, signedDecided *specqbft.SignedMessage) bool

IsDecidedMsg returns true if signed commit has all quorum sigs

func ValidateDecided

func ValidateDecided(
	config qbft.IConfig,
	signedDecided *specqbft.SignedMessage,
	share *spectypes.Share,
) error

Types

type Controller

type Controller struct {
	Identifier []byte
	Height     specqbft.Height // incremental Height for InstanceContainer
	// StoredInstances stores the last HistoricalInstanceCapacity in an array for message processing purposes.
	StoredInstances   InstanceContainer
	Share             *spectypes.Share
	NewDecidedHandler NewDecidedHandler `json:"-"`
	// contains filtered or unexported fields
}

Controller is a QBFT coordinator responsible for starting and following the entire life cycle of multiple QBFT InstanceContainer

func NewController

func NewController(
	identifier []byte,
	share *spectypes.Share,
	config qbft.IConfig,
	fullNode bool,
) *Controller

func (*Controller) BaseMsgValidation

func (c *Controller) BaseMsgValidation(msg *specqbft.SignedMessage) error

BaseMsgValidation returns error if msg is invalid (base validation)

func (*Controller) Decode

func (c *Controller) Decode(data []byte) error

Decode implementation

func (*Controller) Encode

func (c *Controller) Encode() ([]byte, error)

Encode implementation

func (*Controller) GetConfig

func (c *Controller) GetConfig() qbft.IConfig

func (*Controller) GetIdentifier

func (c *Controller) GetIdentifier() []byte

GetIdentifier returns QBFT Identifier, used to identify messages

func (*Controller) GetRoot

func (c *Controller) GetRoot() ([32]byte, error)

GetRoot returns the state's deterministic root

func (*Controller) InstanceForHeight

func (c *Controller) InstanceForHeight(logger *zap.Logger, height specqbft.Height) *instance.Instance

func (*Controller) LoadHighestInstance

func (c *Controller) LoadHighestInstance(identifier []byte) (*instance.Instance, error)

func (*Controller) OnTimeout

func (c *Controller) OnTimeout(logger *zap.Logger, msg types.EventMsg) error

OnTimeout is trigger upon timeout for the given height

func (*Controller) ProcessMsg

func (c *Controller) ProcessMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (*specqbft.SignedMessage, error)

ProcessMsg processes a new msg, returns decided message or error

func (*Controller) SaveInstance

func (c *Controller) SaveInstance(i *instance.Instance, msg *specqbft.SignedMessage) error

SaveInstance saves the given instance to the storage.

func (*Controller) StartNewInstance

func (c *Controller) StartNewInstance(logger *zap.Logger, height specqbft.Height, value []byte) error

StartNewInstance will start a new QBFT instance, if can't will return error

func (*Controller) UponDecided

func (c *Controller) UponDecided(logger *zap.Logger, msg *specqbft.SignedMessage) (*specqbft.SignedMessage, error)

UponDecided returns decided msg if decided, nil otherwise

func (*Controller) UponExistingInstanceMsg

func (c *Controller) UponExistingInstanceMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (*specqbft.SignedMessage, error)

type InstanceContainer

type InstanceContainer []*instance.Instance

InstanceContainer is a fixed-capacity container for instances.

func (InstanceContainer) FindInstance

func (i InstanceContainer) FindInstance(height specqbft.Height) *instance.Instance

func (*InstanceContainer) String

func (i *InstanceContainer) String() string

String returns a human-readable representation of the instances. Useful for debugging.

type NewDecidedHandler

type NewDecidedHandler func(msg *specqbft.SignedMessage)

NewDecidedHandler handles newly saved decided messages. it will be called in a new goroutine to avoid concurrency issues

Jump to

Keyboard shortcuts

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