From 42e345788422ea732d45aa5ef0273db4db08b466 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 19 Mar 2018 10:06:25 +0300 Subject: [PATCH] fix tracking of votes and blockparts to not allow old information also remove mutex Refs #1317 --- consensus/reactor.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index 6b1eb9b6f..5c4446bf5 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -1079,10 +1079,7 @@ func (ps *PeerState) ensureVoteBitArrays(height int64, numValidators int) { // It returns the total number of votes (1 per block). This essentially means // the number of blocks for which peer has been sending us votes. func (ps *PeerState) RecordVote(vote *types.Vote) int { - ps.mtx.Lock() - defer ps.mtx.Unlock() - - if ps.stats.lastVoteHeight == vote.Height { + if ps.stats.lastVoteHeight >= vote.Height { return ps.stats.votes } ps.stats.lastVoteHeight = vote.Height @@ -1094,10 +1091,7 @@ func (ps *PeerState) RecordVote(vote *types.Vote) int { // It returns the total number of block parts (1 per block). This essentially means // the number of blocks for which peer has been sending us block parts. func (ps *PeerState) RecordBlockPart(bp *BlockPartMessage) int { - ps.mtx.Lock() - defer ps.mtx.Unlock() - - if ps.stats.lastBlockPartHeight == bp.Height { + if ps.stats.lastBlockPartHeight >= bp.Height { return ps.stats.blockParts }