change FINISHED to Finished

pull/75/head
Minh Doan 6 years ago
parent c7908e8821
commit 37a9d84216
  1. 2
      consensus/consensus.go
  2. 14
      consensus/consensus_leader.go
  3. 10
      consensus/consensus_state.go

@ -184,7 +184,7 @@ func (consensus *Consensus) GetValidatorPeers() []p2p.Peer {
// Reset the state of the consensus
func (consensus *Consensus) ResetState() {
consensus.state = FINISHED
consensus.state = Finished
consensus.commitments = &map[uint16]kyber.Point{}
consensus.finalCommitments = &map[uint16]kyber.Point{}
consensus.responses = &map[uint16]kyber.Scalar{}

@ -31,7 +31,7 @@ func (consensus *Consensus) WaitForNewBlock(blockChannel chan blockchain.Block)
// TODO: think about potential race condition
startTime = time.Now()
consensus.Log.Debug("STARTING CONSENSUS", "consensus", consensus, "startTime", startTime)
for consensus.state == FINISHED {
for consensus.state == Finished {
// time.Sleep(500 * time.Millisecond)
consensus.startConsensus(&newBlock)
break
@ -61,7 +61,7 @@ func (consensus *Consensus) ProcessMessageLeader(message []byte) {
case proto_consensus.FinalCommit:
consensus.processCommitMessage(payload, FinalChallengeDone)
case proto_consensus.FinalResponse:
consensus.processResponseMessage(payload, FINISHED)
consensus.processResponseMessage(payload, Finished)
default:
consensus.Log.Error("Unexpected message type", "msgType", msgType, "consensus", consensus)
}
@ -286,7 +286,7 @@ func (consensus *Consensus) processResponseMessage(payload []byte, targetState C
commitments := consensus.commitments // targetState == CollectiveSigDone
responses := consensus.responses
bitmap := consensus.bitmap
if targetState == FINISHED {
if targetState == Finished {
commitments = consensus.finalCommitments
responses = consensus.finalResponses
bitmap = consensus.finalBitmap
@ -335,7 +335,7 @@ func (consensus *Consensus) processResponseMessage(payload []byte, targetState C
return
}
aggregatedCommitment := consensus.aggregatedCommitment
if targetState == FINISHED {
if targetState == Finished {
aggregatedCommitment = consensus.aggregatedFinalCommitment
}
@ -352,10 +352,10 @@ func (consensus *Consensus) processResponseMessage(payload []byte, targetState C
copy(collectiveSig[:], collectiveSigAndBitmap[:64])
bitmap := collectiveSigAndBitmap[64:]
// Set state to CollectiveSigDone or FINISHED
// Set state to CollectiveSigDone or Finished
consensus.state = targetState
if consensus.state != FINISHED {
if consensus.state != Finished {
// Start the second round of Cosi
msgToSend := consensus.constructCollectiveSigMessage(collectiveSig, bitmap)
@ -363,7 +363,7 @@ func (consensus *Consensus) processResponseMessage(payload []byte, targetState C
consensus.commitByLeader(false)
} else {
consensus.Log.Debug("Consensus reached with signatures.", "numOfSignatures", len(*responses))
// Reset state to FINISHED, and clear other data.
// Reset state to Finished, and clear other data.
consensus.ResetState()
consensus.consensusID++
consensus.Log.Debug("HOORAY!!! CONSENSUS REACHED!!!", "consensusID", consensus.consensusID)

@ -2,13 +2,13 @@ package consensus
// Consensus state enum for both leader and validator
// States for leader:
// FINISHED, AnnounceDone, ChallengeDone
// Finished, AnnounceDone, ChallengeDone
// States for validator:
// FINISHED, CommitDone, ResponseDone
// Finished, CommitDone, ResponseDone
type ConsensusState int
const (
FINISHED ConsensusState = iota // initial state or state after previous consensus is done.
Finished ConsensusState = iota // initial state or state after previous consensus is done.
AnnounceDone
CommitDone
ChallengeDone
@ -22,7 +22,7 @@ const (
// Returns string name for the ConsensusState enum
func (state ConsensusState) String() string {
names := [...]string{
"FINISHED",
"Finished",
"AnnounceDone",
"CommitDone",
"ChallengeDone",
@ -32,7 +32,7 @@ func (state ConsensusState) String() string {
"FinalChallengeDone",
"FinalResponseDone"}
if state < FINISHED || state > FinalResponseDone {
if state < Finished || state > FinalResponseDone {
return "Unknown"
}
return names[state]

Loading…
Cancel
Save