From 3c0128a680023324c3c936be8a0f10d76c8b6f33 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 23 Jun 2017 21:36:47 -0400 Subject: [PATCH] undo some megacheck suggestions --- blockchain/pool.go | 10 +++++----- blockchain/reactor.go | 3 +-- consensus/state.go | 20 ++++++++++---------- p2p/connection.go | 6 +++--- state/execution.go | 4 ++-- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/blockchain/pool.go b/blockchain/pool.go index 49e255883..a95589987 100644 --- a/blockchain/pool.go +++ b/blockchain/pool.go @@ -212,9 +212,9 @@ func (pool *BlockPool) AddBlock(peerID string, block *types.Block, blockSize int pool.numPending-- peer := pool.peers[peerID] peer.decrPending(blockSize) - } // else { - // Bad peer? - // } + } else { + // Bad peer? + } } // Sets the peer's alleged blockchain height. @@ -303,7 +303,7 @@ func (pool *BlockPool) sendTimeout(peerID string) { } // unused by tendermint; left for debugging purposes -/*func (pool *BlockPool) debug() string { +func (pool *BlockPool) debug() string { pool.mtx.Lock() // Lock defer pool.mtx.Unlock() @@ -317,7 +317,7 @@ func (pool *BlockPool) sendTimeout(peerID string) { } } return str -}*/ +} //------------------------------------- diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 670396b02..8e8b49403 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -132,8 +132,7 @@ func (bcR *BlockchainReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte) bcR.Logger.Debug("Receive", "src", src, "chID", chID, "msg", msg) - // [zr] note: the `megacheck` tool (go vet on steroids) - // really dislikes the logic in this switch + // TODO: improve logic to satisfy megacheck switch msg := msg.(type) { case *bcBlockRequestMessage: // Got a request for a block. Respond with block if we have it. diff --git a/consensus/state.go b/consensus/state.go index 9d9c75851..c398eb312 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -649,9 +649,9 @@ func (cs *ConsensusState) handleMsg(mi msgInfo, rs RoundState) { // attempt to add the vote and dupeout the validator if its a duplicate signature // if the vote gives us a 2/3-any or 2/3-one, we transition _ = cs.tryAddVote(msg.Vote, peerKey) - //if err == ErrAddingVote { - // TODO: punish peer - //} + if err == ErrAddingVote { + // TODO: punish peer + } // NOTE: the vote is broadcast to peers by the reactor listening // for vote events @@ -897,10 +897,10 @@ func (cs *ConsensusState) enterPrevote(height int, round int) { // fire event for how we got here if cs.isProposalComplete() { types.FireEventCompleteProposal(cs.evsw, cs.RoundStateEvent()) - } // else { - // we received +2/3 prevotes for a future round - // TODO: catchup event? - //} + } else { + // we received +2/3 prevotes for a future round + // TODO: catchup event? + } cs.Logger.Info(cmn.Fmt("enterPrevote(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step)) @@ -1122,9 +1122,9 @@ func (cs *ConsensusState) enterCommit(height int, commitRound int) { // Set up ProposalBlockParts and keep waiting. cs.ProposalBlock = nil cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartsHeader) - } // else { - // We just need to keep waiting. - //} + } else { + // We just need to keep waiting. + } } } diff --git a/p2p/connection.go b/p2p/connection.go index 1e3da1778..e167c7740 100644 --- a/p2p/connection.go +++ b/p2p/connection.go @@ -366,9 +366,9 @@ func (c *MConnection) sendMsgPacket() bool { // Nothing to send? if leastChannel == nil { return true - } // else { - // c.Logger.Info("Found a msgPacket to send") - //} + } else { + // c.Logger.Info("Found a msgPacket to send") + } // Make & send a msgPacket from this channel n, err := leastChannel.writeMsgPacketTo(c.bufWriter) diff --git a/state/execution.go b/state/execution.go index 2a64f1885..768a0b1de 100644 --- a/state/execution.go +++ b/state/execution.go @@ -157,7 +157,7 @@ func updateValidators(validators *types.ValidatorSet, changedValidators []*abci. // return a bit array of validators that signed the last commit // NOTE: assumes commits have already been authenticated -/*func commitBitArrayFromBlock(block *types.Block) *cmn.BitArray { +func commitBitArrayFromBlock(block *types.Block) *cmn.BitArray { signed := cmn.NewBitArray(len(block.LastCommit.Precommits)) for i, precommit := range block.LastCommit.Precommits { if precommit != nil { @@ -165,7 +165,7 @@ func updateValidators(validators *types.ValidatorSet, changedValidators []*abci. } } return signed -}*/ +} //----------------------------------------------------- // Validate block