github.com/iotexproject/iotex-core@v1.14.1-rc1/consensus/consensusfsm/context.go (about) 1 // Copyright (c) 2019 IoTeX Foundation 2 // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability 3 // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed. 4 // This source code is governed by Apache License 2.0 that can be found in the LICENSE file. 5 6 package consensusfsm 7 8 import ( 9 "time" 10 11 fsm "github.com/iotexproject/go-fsm" 12 "go.uber.org/zap" 13 14 "github.com/iotexproject/iotex-core/pkg/lifecycle" 15 ) 16 17 // Context defines the context of the fsm 18 type Context interface { 19 lifecycle.StartStopper 20 Activate(bool) 21 Active() bool 22 IsStaleEvent(*ConsensusEvent) bool 23 IsFutureEvent(*ConsensusEvent) bool 24 IsStaleUnmatchedEvent(*ConsensusEvent) bool 25 26 Logger() *zap.Logger 27 Height() uint64 28 29 NewConsensusEvent(fsm.EventType, interface{}) *ConsensusEvent 30 NewBackdoorEvt(fsm.State) *ConsensusEvent 31 32 Broadcast(interface{}) 33 34 Prepare() error 35 IsDelegate() bool 36 Proposal() (interface{}, error) 37 WaitUntilRoundStart() time.Duration 38 PreCommitEndorsement() interface{} 39 NewProposalEndorsement(interface{}) (interface{}, error) 40 NewLockEndorsement(interface{}) (interface{}, error) 41 NewPreCommitEndorsement(interface{}) (interface{}, error) 42 Commit(interface{}) (bool, error) 43 ConsensusConfig 44 }