-
Notifications
You must be signed in to change notification settings - Fork 321
/
context.go
51 lines (39 loc) · 1.43 KB
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2019 IoTeX
// This is an alpha (internal) release and is not suitable for production. This source code is provided 'as is' and no
// warranties are given as to title or non-infringement, merchantability or fitness for purpose and, to the extent
// permitted by law, all liability for your use of the code is disclaimed. This source code is governed by Apache
// License 2.0 that can be found in the LICENSE file.
package consensusfsm
import (
"time"
fsm "github.com/iotexproject/go-fsm"
"go.uber.org/zap"
)
// Context defines the context of the fsm
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
}