Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - Variables
 - type Config
 - type Consensus
 - type IotxConsensus
 - func (c *IotxConsensus) Activate(active bool)
 - func (c *IotxConsensus) Active() bool
 - func (c *IotxConsensus) Calibrate(height uint64)
 - func (c *IotxConsensus) HandleConsensusMsg(msg *iotextypes.ConsensusMessage) error
 - func (c *IotxConsensus) Metrics() (scheme.ConsensusMetrics, error)
 - func (c *IotxConsensus) Scheme() scheme.Scheme
 - func (c *IotxConsensus) Start(ctx context.Context) error
 - func (c *IotxConsensus) Stop(ctx context.Context) error
 - func (c *IotxConsensus) ValidateBlockFooter(blk *block.Block) error
 
- type Option
 
Constants ¶
const ( // RollDPoSScheme means randomized delegated proof of stake RollDPoSScheme = "ROLLDPOS" // StandaloneScheme means that the node creates a block periodically regardless of others (if there is any) StandaloneScheme = "STANDALONE" // NOOPScheme means that the node does not create only block NOOPScheme = "NOOP" )
Variables ¶
var ( //DefaultConfig is the default config for blocksync DefaultConfig = Config{ Scheme: StandaloneScheme, RollDPoS: rolldpos.DefaultConfig, } )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
	// There are three schemes that are supported
	Scheme   string          `yaml:"scheme"`
	RollDPoS rolldpos.Config `yaml:"rollDPoS"`
}
    Config is the config struct for consensus package
type Consensus ¶
type Consensus interface {
	lifecycle.StartStopper
	HandleConsensusMsg(*iotextypes.ConsensusMessage) error
	Calibrate(uint64)
	Metrics() (scheme.ConsensusMetrics, error)
	Activate(bool)
	Active() bool
}
    Consensus is the interface for handling IotxConsensus view change.
func NewConsensus ¶
func NewConsensus( cfg rolldpos.BuilderConfig, bc blockchain.Blockchain, sf rolldpos.StateReaderFactory, opts ...Option, ) (Consensus, error)
NewConsensus creates a IotxConsensus struct.
type IotxConsensus ¶
type IotxConsensus struct {
	// contains filtered or unexported fields
}
    IotxConsensus implements Consensus
func (*IotxConsensus) Activate ¶
func (c *IotxConsensus) Activate(active bool)
Activate activates or pauses the consensus component
func (*IotxConsensus) Active ¶
func (c *IotxConsensus) Active() bool
Active returns true if the consensus component is active or false if it stands by
func (*IotxConsensus) Calibrate ¶
func (c *IotxConsensus) Calibrate(height uint64)
Calibrate triggers an event to calibrate consensus context
func (*IotxConsensus) HandleConsensusMsg ¶
func (c *IotxConsensus) HandleConsensusMsg(msg *iotextypes.ConsensusMessage) error
HandleConsensusMsg handles consensus messages
func (*IotxConsensus) Metrics ¶
func (c *IotxConsensus) Metrics() (scheme.ConsensusMetrics, error)
Metrics returns consensus metrics
func (*IotxConsensus) Scheme ¶
func (c *IotxConsensus) Scheme() scheme.Scheme
Scheme returns the scheme instance
func (*IotxConsensus) Start ¶
func (c *IotxConsensus) Start(ctx context.Context) error
Start starts running the consensus algorithm
func (*IotxConsensus) Stop ¶
func (c *IotxConsensus) Stop(ctx context.Context) error
Stop stops running the consensus algorithm
func (*IotxConsensus) ValidateBlockFooter ¶
func (c *IotxConsensus) ValidateBlockFooter(blk *block.Block) error
ValidateBlockFooter validates the signatures in block footer
type Option ¶
type Option func(op *optionParams) error
Option sets Consensus construction parameter.
func WithBlockBuilderFactory ¶ added in v2.2.0
func WithBlockBuilderFactory(bbf rolldpos.BlockBuilderFactory) Option
WithBlockBuilderFactory is an option to set block builder factory
func WithBroadcast ¶
WithBroadcast is an option to add broadcast callback to Consensus
func WithPollProtocol ¶
WithPollProtocol is an option to register poll protocol
func WithRollDPoSProtocol ¶
WithRollDPoSProtocol is an option to register rolldpos protocol