-
Notifications
You must be signed in to change notification settings - Fork 0
/
enums.go
executable file
·58 lines (50 loc) · 978 Bytes
/
enums.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
52
53
54
55
56
57
58
package consensus
import "fmt"
// Mode is the current
type Mode byte
const (
// Normal ..
Normal Mode = iota
// ViewChanging ..
ViewChanging
// Syncing ..
Syncing
// Listening ..
Listening
// NormalBackup Backup Node ..
NormalBackup
)
// FBFTPhase : different phases of consensus
type FBFTPhase byte
// Enum for FBFTPhase
const (
FBFTAnnounce FBFTPhase = iota
FBFTPrepare
FBFTCommit
)
var (
modeNames = map[Mode]string{
Normal: "Normal",
ViewChanging: "ViewChanging",
Syncing: "Syncing",
Listening: "Listening",
NormalBackup: "NormalBackup",
}
phaseNames = map[FBFTPhase]string{
FBFTAnnounce: "Announce",
FBFTPrepare: "Prepare",
FBFTCommit: "Commit",
}
)
func (m Mode) String() string {
if name, ok := modeNames[m]; ok {
return name
}
return fmt.Sprintf("Mode %+v", byte(m))
}
func (p FBFTPhase) String() string {
if name, ok := phaseNames[p]; ok {
return name
}
return fmt.Sprintf("FBFTPhase %+v", byte(p))
}