From 5fab8e404de52a3e031ae12d9117e2b448cd69fc Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 19 Mar 2018 09:55:08 +0300 Subject: [PATCH] replace magic number with blocksToContributeToBecomeGoodPeer const Refs #1317 --- consensus/reactor.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index 5c672a0c..2c61464d 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -27,6 +27,8 @@ const ( VoteSetBitsChannel = byte(0x23) maxConsensusMessageSize = 1048576 // 1MB; NOTE/TODO: keep in sync with types.PartSet sizes. + + blocksToContributeToBecomeGoodPeer = 10000 ) //----------------------------------------------------------------------------- @@ -251,7 +253,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) ps.ApplyProposalPOLMessage(msg) case *BlockPartMessage: ps.SetHasProposalBlockPart(msg.Height, msg.Round, msg.Part.Index) - if numBlocks := ps.RecordBlockPart(msg); numBlocks > 10000 { + if numBlocks := ps.RecordBlockPart(msg); numBlocks > blocksToContributeToBecomeGoodPeer { conR.Switch.MarkPeerAsGood(src) } conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()} @@ -273,7 +275,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) ps.EnsureVoteBitArrays(height, valSize) ps.EnsureVoteBitArrays(height-1, lastCommitSize) ps.SetHasVote(msg.Vote) - if blocks := ps.RecordVote(msg.Vote); blocks > 10000 { + if blocks := ps.RecordVote(msg.Vote); blocks > blocksToContributeToBecomeGoodPeer { conR.Switch.MarkPeerAsGood(src) }