Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type ConsensusEvent
- type ConsensusFSM
- func (m *ConsensusFSM) Calibrate(height uint64)
- func (m *ConsensusFSM) CurrentState() fsm.State
- func (m *ConsensusFSM) NumPendingEvents() int
- func (m *ConsensusFSM) ProducePrepareEvent(delay time.Duration)
- func (m *ConsensusFSM) ProduceReceiveBlockEvent(block Endorsement)
- func (m *ConsensusFSM) ProduceReceiveLockEndorsementEvent(endorsement Endorsement)
- func (m *ConsensusFSM) ProduceReceivePreCommitEndorsementEvent(endorsement Endorsement)
- func (m *ConsensusFSM) ProduceReceiveProposalEndorsementEvent(endorsement Endorsement)
- func (m *ConsensusFSM) Start(c context.Context) error
- func (m *ConsensusFSM) Stop(_ context.Context) error
- type Context
- type Endorsement
Constants ¶
const ( // BackdoorEvent indicates a backdoor event type BackdoorEvent fsm.EventType = "E_BACKDOOR" )
Variables ¶
var ( // ErrEvtCast indicates the error of casting the event ErrEvtCast = errors.New("error when casting the event") // ErrEvtConvert indicates the error of converting the event from/to the proto message ErrEvtConvert = errors.New("error when converting the event from/to the proto message") // ErrEvtType represents an unexpected event type error ErrEvtType = errors.New("error when check the event type") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { EventChanSize uint `yaml:"eventChanSize"` UnmatchedEventTTL time.Duration `yaml:"unmatchedEventTTL"` UnmatchedEventInterval time.Duration `yaml:"unmatchedEventInterval"` AcceptBlockTTL time.Duration `yaml:"acceptBlockTTL"` AcceptProposalEndorsementTTL time.Duration `yaml:"acceptProposalEndorsementTTL"` AcceptLockEndorsementTTL time.Duration `yaml:"acceptLockEndorsementTTL"` }
Config defines a set of time durations used in fsm and event queue size
type ConsensusEvent ¶
ConsensusEvent defines the event used in the fsm
func NewConsensusEvent ¶
func NewConsensusEvent( eventType fsm.EventType, data interface{}, height uint64, round uint32, creationTime time.Time, ) *ConsensusEvent
NewConsensusEvent creates a new consensus event
func NewConsensusEventWithEndorsement ¶
func NewConsensusEventWithEndorsement( eventType fsm.EventType, en Endorsement, creationTime time.Time, ) *ConsensusEvent
NewConsensusEventWithEndorsement creates a consensus event with endorsement
func (*ConsensusEvent) Data ¶
func (e *ConsensusEvent) Data() interface{}
Data returns the data of the event
func (*ConsensusEvent) Height ¶
func (e *ConsensusEvent) Height() uint64
Height is the height of the event
func (*ConsensusEvent) Round ¶
func (e *ConsensusEvent) Round() uint32
Round is the round of the event
func (*ConsensusEvent) Timestamp ¶
func (e *ConsensusEvent) Timestamp() time.Time
Timestamp is the creation time of the event
func (*ConsensusEvent) Type ¶
func (e *ConsensusEvent) Type() fsm.EventType
Type returns the event type
type ConsensusFSM ¶
type ConsensusFSM struct {
// contains filtered or unexported fields
}
ConsensusFSM wraps over the general purpose FSM and implements the consensus logic
func NewConsensusFSM ¶
NewConsensusFSM returns a new fsm
func (*ConsensusFSM) Calibrate ¶
func (m *ConsensusFSM) Calibrate(height uint64)
Calibrate calibrates the state if necessary
func (*ConsensusFSM) CurrentState ¶
func (m *ConsensusFSM) CurrentState() fsm.State
CurrentState returns the current state
func (*ConsensusFSM) NumPendingEvents ¶
func (m *ConsensusFSM) NumPendingEvents() int
NumPendingEvents returns the number of pending events
func (*ConsensusFSM) ProducePrepareEvent ¶
func (m *ConsensusFSM) ProducePrepareEvent(delay time.Duration)
ProducePrepareEvent produces an ePrepare event after delay
func (*ConsensusFSM) ProduceReceiveBlockEvent ¶
func (m *ConsensusFSM) ProduceReceiveBlockEvent(block Endorsement)
ProduceReceiveBlockEvent produces an eReceiveBlock event after delay
func (*ConsensusFSM) ProduceReceiveLockEndorsementEvent ¶
func (m *ConsensusFSM) ProduceReceiveLockEndorsementEvent(endorsement Endorsement)
ProduceReceiveLockEndorsementEvent produces an eReceiveLockEndorsement event right away
func (*ConsensusFSM) ProduceReceivePreCommitEndorsementEvent ¶
func (m *ConsensusFSM) ProduceReceivePreCommitEndorsementEvent(endorsement Endorsement)
ProduceReceivePreCommitEndorsementEvent produces an eReceivePreCommitEndorsement event right away
func (*ConsensusFSM) ProduceReceiveProposalEndorsementEvent ¶
func (m *ConsensusFSM) ProduceReceiveProposalEndorsementEvent(endorsement Endorsement)
ProduceReceiveProposalEndorsementEvent produces an eReceiveProposalEndorsement event right away
type Context ¶
type Context interface { IsStaleEvent(*ConsensusEvent) bool IsFutureEvent(*ConsensusEvent) bool IsStaleUnmatchedEvent(*ConsensusEvent) bool Logger() *zap.Logger LoggerWithStats() *zap.Logger Height() uint64 NewConsensusEvent(fsm.EventType, interface{}) *ConsensusEvent NewBackdoorEvt(fsm.State) *ConsensusEvent IsDelegate() bool IsProposer() bool BroadcastBlockProposal(Endorsement) BroadcastEndorsement(Endorsement) Prepare() (time.Duration, error) MintBlock() (Endorsement, error) NewProposalEndorsement(Endorsement) (Endorsement, error) NewLockEndorsement() (Endorsement, error) NewPreCommitEndorsement() (Endorsement, error) OnConsensusReached() AddProposalEndorsement(Endorsement) error AddLockEndorsement(Endorsement) error AddPreCommitEndorsement(Endorsement) error HasReceivedBlock() bool IsLocked() bool ReadyToPreCommit() bool ReadyToCommit() bool }
Context defines the context of the fsm