Documentation ¶
Index ¶
- Constants
- Variables
- type ConsensusConfig
- type ConsensusEvent
- type ConsensusFSM
- func (m *ConsensusFSM) BackToPrepare(delay time.Duration) (fsm.State, error)
- func (m *ConsensusFSM) Calibrate(height uint64)
- func (m *ConsensusFSM) CurrentState() fsm.State
- func (m *ConsensusFSM) NumPendingEvents() int
- func (m *ConsensusFSM) ProduceReceiveBlockEvent(block interface{})
- func (m *ConsensusFSM) ProduceReceiveLockEndorsementEvent(vote interface{})
- func (m *ConsensusFSM) ProduceReceivePreCommitEndorsementEvent(vote interface{})
- func (m *ConsensusFSM) ProduceReceiveProposalEndorsementEvent(vote interface{})
- func (m *ConsensusFSM) Start(c context.Context) error
- func (m *ConsensusFSM) Stop(_ context.Context) error
- type ConsensusTiming
- type Context
- type DardanellesUpgrade
- type EndorsedMessage
Constants ¶
const ( // BackdoorEvent indicates a backdoor event type BackdoorEvent fsm.EventType = "E_BACKDOOR" // InitState refers the initial state of the consensus fsm InitState = sPrepare )
Variables ¶
var ( // ErrEvtCast indicates the error of casting the event ErrEvtCast = errors.New("error when casting the event") // ErrMsgCast indicates the error of casting to endorsed message ErrMsgCast = errors.New("error when casting to endorsed message") // 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") // ErrOldCalibrateEvt indicates the error of ignoring old calibrate event ErrOldCalibrateEvt = errors.New("ignore old calibrate event") )
var DefaultDardanellesUpgradeConfig = DardanellesUpgrade{ UnmatchedEventTTL: 2 * time.Second, UnmatchedEventInterval: 100 * time.Millisecond, AcceptBlockTTL: 2 * time.Second, AcceptProposalEndorsementTTL: time.Second, AcceptLockEndorsementTTL: time.Second, CommitTTL: time.Second, BlockInterval: 5 * time.Second, Delay: 2 * time.Second, }
DefaultDardanellesUpgradeConfig is the default config for dardanelles upgrade
Functions ¶
This section is empty.
Types ¶
type ConsensusConfig ¶
type ConsensusConfig interface { EventChanSize() uint UnmatchedEventTTL(uint64) time.Duration UnmatchedEventInterval(uint64) time.Duration AcceptBlockTTL(uint64) time.Duration AcceptProposalEndorsementTTL(uint64) time.Duration AcceptLockEndorsementTTL(uint64) time.Duration CommitTTL(uint64) time.Duration BlockInterval(uint64) time.Duration Delay(uint64) time.Duration }
ConsensusConfig defines a set of time durations used in fsm
func NewConsensusConfig ¶
func NewConsensusConfig(timing ConsensusTiming, dardanelles DardanellesUpgrade, g genesis.Genesis, delay time.Duration) ConsensusConfig
NewConsensusConfig creates a ConsensusConfig out of config.
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 (*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 ¶
func NewConsensusFSM(ctx Context, clock clock.Clock) (*ConsensusFSM, error)
NewConsensusFSM returns a new fsm
func (*ConsensusFSM) BackToPrepare ¶
BackToPrepare produces an ePrepare event after delay
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) ProduceReceiveBlockEvent ¶
func (m *ConsensusFSM) ProduceReceiveBlockEvent(block interface{})
ProduceReceiveBlockEvent produces an eReceiveBlock event after delay
func (*ConsensusFSM) ProduceReceiveLockEndorsementEvent ¶
func (m *ConsensusFSM) ProduceReceiveLockEndorsementEvent(vote interface{})
ProduceReceiveLockEndorsementEvent produces an eReceiveLockEndorsement event right away
func (*ConsensusFSM) ProduceReceivePreCommitEndorsementEvent ¶
func (m *ConsensusFSM) ProduceReceivePreCommitEndorsementEvent(vote interface{})
ProduceReceivePreCommitEndorsementEvent produces an eReceivePreCommitEndorsement event right away
func (*ConsensusFSM) ProduceReceiveProposalEndorsementEvent ¶
func (m *ConsensusFSM) ProduceReceiveProposalEndorsementEvent(vote interface{})
ProduceReceiveProposalEndorsementEvent produces an eReceiveProposalEndorsement event right away
type ConsensusTiming ¶
type ConsensusTiming 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"` CommitTTL time.Duration `yaml:"commitTTL"` }
ConsensusTiming defines a set of time durations used in fsm and event queue size
type Context ¶
type Context interface { lifecycle.StartStopper Activate(bool) Active() bool IsStaleEvent(*ConsensusEvent) bool IsFutureEvent(*ConsensusEvent) bool IsStaleUnmatchedEvent(*ConsensusEvent) bool Logger() *zap.Logger Height() uint64 NewConsensusEvent(fsm.EventType, interface{}) *ConsensusEvent NewBackdoorEvt(fsm.State) *ConsensusEvent Broadcast(interface{}) Prepare() error IsDelegate() bool Proposal() (interface{}, error) WaitUntilRoundStart() time.Duration PreCommitEndorsement() interface{} NewProposalEndorsement(interface{}) (interface{}, error) NewLockEndorsement(interface{}) (interface{}, error) NewPreCommitEndorsement(interface{}) (interface{}, error) Commit(interface{}) (bool, error) ConsensusConfig }
Context defines the context of the fsm
type DardanellesUpgrade ¶
type DardanellesUpgrade struct { 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"` CommitTTL time.Duration `yaml:"commitTTL"` BlockInterval time.Duration `yaml:"blockInterval"` Delay time.Duration `yaml:"delay"` }
DardanellesUpgrade is the config for dardanelles upgrade
type EndorsedMessage ¶
type EndorsedMessage interface { Endorsement() *endorsement.Endorsement Message() interface{} }
EndorsedMessage defines a message with endorsement