From ba1796126993fe3279a6c0a14c7c5fc911b59a25 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Wed, 6 May 2015 11:39:59 -0700 Subject: [PATCH] Always return the validatorIndex upon AddVote() --- consensus/vote_set.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/consensus/vote_set.go b/consensus/vote_set.go index fafee1d44..21e986617 100644 --- a/consensus/vote_set.go +++ b/consensus/vote_set.go @@ -73,6 +73,7 @@ func (voteSet *VoteSet) Size() uint { // True if added, false if not. // Returns ErrVote[UnexpectedStep|InvalidAccount|InvalidSignature|InvalidBlockHash|ConflictingSignature] // NOTE: vote should not be mutated after adding. +// Returns the validator index of the vote unless error is set. func (voteSet *VoteSet) Add(address []byte, vote *types.Vote) (bool, uint, error) { voteSet.mtx.Lock() defer voteSet.mtx.Unlock() @@ -104,9 +105,9 @@ func (voteSet *VoteSet) addVote(valIndex uint, vote *types.Vote) (bool, uint, er // If vote already exists, return false. if existingVote := voteSet.votes[valIndex]; existingVote != nil { if bytes.Equal(existingVote.BlockHash, vote.BlockHash) { - return false, 0, nil + return false, valIndex, nil } else { - return false, 0, &types.ErrVoteConflictingSignature{ + return false, valIndex, &types.ErrVoteConflictingSignature{ VoteA: existingVote, VoteB: vote, }