|
@ -1087,6 +1087,9 @@ func (ps *PeerState) ensureVoteBitArrays(height int64, numValidators int) { |
|
|
// It returns the total number of votes (1 per block). This essentially means
|
|
|
// 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.
|
|
|
// the number of blocks for which peer has been sending us votes.
|
|
|
func (ps *PeerState) RecordVote(vote *types.Vote) int { |
|
|
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 |
|
|
return ps.stats.votes |
|
|
} |
|
|
} |
|
@ -1098,13 +1101,20 @@ func (ps *PeerState) RecordVote(vote *types.Vote) int { |
|
|
// VotesSent returns the number of blocks for which peer has been sending us
|
|
|
// VotesSent returns the number of blocks for which peer has been sending us
|
|
|
// votes.
|
|
|
// votes.
|
|
|
func (ps *PeerState) VotesSent() int { |
|
|
func (ps *PeerState) VotesSent() int { |
|
|
|
|
|
ps.mtx.Lock() |
|
|
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
|
return ps.stats.votes |
|
|
return ps.stats.votes |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// RecordVote updates internal statistics for this peer by recording the block part.
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
// RecordBlockPart updates internal statistics for this peer by recording the
|
|
|
|
|
|
// block part. 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 { |
|
|
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 |
|
|
return ps.stats.blockParts |
|
|
} |
|
|
} |
|
@ -1117,6 +1127,9 @@ func (ps *PeerState) RecordBlockPart(bp *BlockPartMessage) int { |
|
|
// BlockPartsSent returns the number of blocks for which peer has been sending
|
|
|
// BlockPartsSent returns the number of blocks for which peer has been sending
|
|
|
// us block parts.
|
|
|
// us block parts.
|
|
|
func (ps *PeerState) BlockPartsSent() int { |
|
|
func (ps *PeerState) BlockPartsSent() int { |
|
|
|
|
|
ps.mtx.Lock() |
|
|
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
|
return ps.stats.blockParts |
|
|
return ps.stats.blockParts |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|