Browse Source

fix tracking of votes and blockparts to not allow old information

also remove mutex
Refs #1317
pull/1333/head
Anton Kaliaev 7 years ago
parent
commit
42e3457884
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 2 additions and 8 deletions
  1. +2
    -8
      consensus/reactor.go

+ 2
- 8
consensus/reactor.go View File

@ -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
}


Loading…
Cancel
Save