From 7a4b62d3be77425e83b489b9e44f6bdec4246ef5 Mon Sep 17 00:00:00 2001 From: Ismail Khoffi Date: Sun, 11 Nov 2018 13:57:08 +0100 Subject: [PATCH] check the result of `ps.peer.Send` before calling `ps.setHasVote` (#2787) - actually call `ps.SetHasVote` instead to avoid carrying around `votes.Height()`, `votes.Round()`, `types.SignedMsgType(votes.Type())` --- consensus/reactor.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index fc41e5734..12e8e0f14 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -1017,7 +1017,11 @@ func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool { if vote, ok := ps.PickVoteToSend(votes); ok { msg := &VoteMessage{vote} ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote) - return ps.peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg)) + if ps.peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg)) { + ps.SetHasVote(vote) + return true + } + return false } return false } @@ -1046,7 +1050,6 @@ func (ps *PeerState) PickVoteToSend(votes types.VoteSetReader) (vote *types.Vote return nil, false // Not something worth sending } if index, ok := votes.BitArray().Sub(psVotes).PickRandom(); ok { - ps.setHasVote(height, round, type_, index) return votes.GetByIndex(index), true } return nil, false