You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
855 B
40 lines
855 B
package consensus
|
|
|
|
// State is the consensus state enum for both leader and validator
|
|
// States for leader:
|
|
// Finished, AnnounceDone, ChallengeDone
|
|
// States for validator:
|
|
// Finished, CommitDone, ResponseDone
|
|
type State int
|
|
|
|
// Followings are the set of states of validators or leaders during consensus.
|
|
const (
|
|
Finished State = iota
|
|
AnnounceDone
|
|
CommitDone
|
|
ChallengeDone
|
|
ResponseDone
|
|
CollectiveSigDone
|
|
FinalCommitDone
|
|
FinalChallengeDone
|
|
FinalResponseDone
|
|
)
|
|
|
|
// Returns string name for the State enum
|
|
func (state State) String() string {
|
|
names := [...]string{
|
|
"Finished",
|
|
"AnnounceDone",
|
|
"CommitDone",
|
|
"ChallengeDone",
|
|
"ResponseDone",
|
|
"CollectiveSigDone",
|
|
"FinalCommitDone",
|
|
"FinalChallengeDone",
|
|
"FinalResponseDone"}
|
|
|
|
if state < Finished || state > FinalResponseDone {
|
|
return "Unknown"
|
|
}
|
|
return names[state]
|
|
}
|
|
|