rolldpos

package
v1.6.2-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 27 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNewRollDPoS indicates the error of constructing RollDPoS
	ErrNewRollDPoS = errors.New("error when constructing RollDPoS")
	// ErrZeroDelegate indicates seeing 0 delegates in the network
	ErrZeroDelegate = errors.New("zero delegates in the network")
	// ErrNotEnoughCandidates indicates there are not enough candidates from the candidate pool
	ErrNotEnoughCandidates = errors.New("Candidate pool does not have enough candidates")
)
View Source
var (
	// ErrExpiredEndorsement indicates that the endorsement is expired
	ErrExpiredEndorsement = errors.New("the endorsement has been replaced or expired")
)
View Source
var ErrInsufficientEndorsements = errors.New("Insufficient endorsements")

ErrInsufficientEndorsements represents the error that not enough endorsements

Functions

This section is empty.

Types

type Builder added in v0.3.0

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

Builder is the builder for RollDPoS

func NewRollDPoSBuilder added in v0.3.0

func NewRollDPoSBuilder() *Builder

NewRollDPoSBuilder instantiates a Builder instance

func (*Builder) Build added in v0.3.0

func (b *Builder) Build() (*RollDPoS, error)

Build builds a RollDPoS consensus module

func (*Builder) RegisterProtocol added in v0.5.0

func (b *Builder) RegisterProtocol(rp *rolldpos.Protocol) *Builder

RegisterProtocol sets the rolldpos protocol

func (*Builder) SetAddr added in v0.3.0

func (b *Builder) SetAddr(encodedAddr string) *Builder

SetAddr sets the address and key pair for signature

func (*Builder) SetBroadcast added in v0.4.4

func (b *Builder) SetBroadcast(broadcastHandler scheme.Broadcast) *Builder

SetBroadcast sets the broadcast callback

func (*Builder) SetChainManager added in v0.9.0

func (b *Builder) SetChainManager(chain ChainManager) *Builder

SetChainManager sets the blockchain APIs

func (*Builder) SetClock added in v0.3.0

func (b *Builder) SetClock(clock clock.Clock) *Builder

SetClock sets the clock

func (*Builder) SetConfig added in v0.3.0

func (b *Builder) SetConfig(cfg config.Config) *Builder

SetConfig sets config

func (*Builder) SetDelegatesByEpochFunc added in v0.11.0

func (b *Builder) SetDelegatesByEpochFunc(
	delegatesByEpochFunc DelegatesByEpochFunc,
) *Builder

SetDelegatesByEpochFunc sets delegatesByEpochFunc

func (*Builder) SetPriKey added in v0.4.4

func (b *Builder) SetPriKey(priKey crypto.PrivateKey) *Builder

SetPriKey sets the private key

type ChainManager added in v0.9.0

type ChainManager interface {
	// Genesis returns the genesis
	Genesis() genesis.Genesis
	// BlockHeaderByHeight return block header by height
	BlockHeaderByHeight(height uint64) (*block.Header, error)
	// BlockFooterByHeight return block footer by height
	BlockFooterByHeight(height uint64) (*block.Footer, error)
	// MintNewBlock creates a new block with given actions
	// Note: the coinbase transfer will be added to the given transfers when minting a new block
	MintNewBlock(timestamp time.Time) (*block.Block, error)
	// CommitBlock validates and appends a block to the chain
	CommitBlock(blk *block.Block) error
	// ValidateBlock validates a new block before adding it to the blockchain
	ValidateBlock(blk *block.Block) error
	// TipHeight returns tip block's height
	TipHeight() uint64
	// ChainAddress returns chain address on parent chain, the root chain return empty.
	ChainAddress() string
}

ChainManager defines the blockchain interface

type ConsensusVote added in v0.5.0

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

ConsensusVote is a vote on a given topic for a block on a specific height

func NewConsensusVote added in v0.5.0

func NewConsensusVote(
	blkHash []byte,
	topic ConsensusVoteTopic,
) *ConsensusVote

NewConsensusVote creates a consensus vote

func (*ConsensusVote) BlockHash added in v0.5.0

func (v *ConsensusVote) BlockHash() []byte

BlockHash returns the block hash of the consensus vote

func (*ConsensusVote) Hash added in v0.5.0

func (v *ConsensusVote) Hash() ([]byte, error)

Hash returns the hash of this vote

func (*ConsensusVote) LoadProto added in v0.5.0

func (v *ConsensusVote) LoadProto(msg *iotextypes.ConsensusVote) error

LoadProto loads from a protobuf message

func (*ConsensusVote) Proto added in v0.5.0

Proto converts to a protobuf message

func (*ConsensusVote) Topic added in v0.5.0

func (v *ConsensusVote) Topic() ConsensusVoteTopic

Topic returns the topic of the consensus vote

type ConsensusVoteTopic added in v0.5.0

type ConsensusVoteTopic uint8

ConsensusVoteTopic defines the topic of an consensus vote

const (
	// PROPOSAL stands for an consensus vote to endorse a block proposal
	PROPOSAL ConsensusVoteTopic = 0
	// LOCK stands for an consensus vote to endorse a lock on a proposed block
	LOCK ConsensusVoteTopic = 1
	// COMMIT stands for an consensus vote to endorse a block commit
	COMMIT ConsensusVoteTopic = 2
)

type DelegatesByEpochFunc added in v0.11.0

type DelegatesByEpochFunc func(uint64) ([]string, error)

DelegatesByEpochFunc defines a function to overwrite candidates

type EndorsedByMajorityFunc added in v0.8.2

type EndorsedByMajorityFunc func(blockHash []byte, topics []ConsensusVoteTopic) bool

EndorsedByMajorityFunc defines a function to give an information of consensus status

type EndorsedConsensusMessage added in v0.5.0

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

EndorsedConsensusMessage is an endorsement on document

func NewEndorsedConsensusMessage added in v0.5.0

func NewEndorsedConsensusMessage(
	height uint64,
	message endorsement.Document,
	endorsement *endorsement.Endorsement,
) *EndorsedConsensusMessage

NewEndorsedConsensusMessage creates an EndorsedConsensusMessage for an consensus vote

func (*EndorsedConsensusMessage) Document added in v0.5.0

Document returns the endorsed consensus message

func (*EndorsedConsensusMessage) Endorsement added in v0.5.0

func (ecm *EndorsedConsensusMessage) Endorsement() *endorsement.Endorsement

Endorsement returns the endorsement

func (*EndorsedConsensusMessage) Height added in v0.5.0

func (ecm *EndorsedConsensusMessage) Height() uint64

Height returns the height of this message

func (*EndorsedConsensusMessage) LoadProto added in v0.5.0

LoadProto creates an endorsement message from protobuf message

func (*EndorsedConsensusMessage) Proto added in v0.5.0

Proto converts an endorsement to endorse proto

type RollDPoS

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

RollDPoS is Roll-DPoS consensus main entrance

func (*RollDPoS) Activate added in v0.5.0

func (r *RollDPoS) Activate(active bool)

Activate activates or pauses the roll-DPoS consensus. When it is deactivated, the node will finish the current consensus round if it is doing the work and then return the the initial state

func (*RollDPoS) Active added in v0.5.0

func (r *RollDPoS) Active() bool

Active is true if the roll-DPoS consensus is active, or false if it is stand-by

func (*RollDPoS) Calibrate added in v0.4.4

func (r *RollDPoS) Calibrate(height uint64)

Calibrate called on receive a new block not via consensus

func (*RollDPoS) CurrentState added in v0.3.0

func (r *RollDPoS) CurrentState() fsm.State

CurrentState returns the current state

func (*RollDPoS) HandleConsensusMsg added in v0.4.4

func (r *RollDPoS) HandleConsensusMsg(msg *iotextypes.ConsensusMessage) error

HandleConsensusMsg handles incoming consensus message

func (*RollDPoS) Metrics

func (r *RollDPoS) Metrics() (scheme.ConsensusMetrics, error)

Metrics returns RollDPoS consensus metrics

func (*RollDPoS) NumPendingEvts added in v0.3.0

func (r *RollDPoS) NumPendingEvts() int

NumPendingEvts returns the number of pending events

func (*RollDPoS) Start

func (r *RollDPoS) Start(ctx context.Context) error

Start starts RollDPoS consensus

func (*RollDPoS) Stop

func (r *RollDPoS) Stop(ctx context.Context) error

Stop stops RollDPoS consensus

func (*RollDPoS) ValidateBlockFooter added in v0.4.4

func (r *RollDPoS) ValidateBlockFooter(blk *block.Block) error

ValidateBlockFooter validates the signatures in the block footer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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