From 37a9d84216d69b81b51858b62b0f6794ebc25188 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Thu, 1 Nov 2018 16:39:24 -0700 Subject: [PATCH] change FINISHED to Finished --- consensus/consensus.go | 2 +- consensus/consensus_leader.go | 14 +++++++------- consensus/consensus_state.go | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index 156a94b98..27bf48cb2 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.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{} diff --git a/consensus/consensus_leader.go b/consensus/consensus_leader.go index 96a2b3889..dc722b6dd 100644 --- a/consensus/consensus_leader.go +++ b/consensus/consensus_leader.go @@ -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) diff --git a/consensus/consensus_state.go b/consensus/consensus_state.go index 7c6b26469..a8e166327 100644 --- a/consensus/consensus_state.go +++ b/consensus/consensus_state.go @@ -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]