mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-28 10:00:21 +00:00
minor changes from @odeke-em PR #725
This commit is contained in:
@@ -100,9 +100,10 @@ func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Valida
|
||||
}
|
||||
|
||||
// GetByIndex returns the validator by index.
|
||||
// It returns nil values if index >= len(ValidatorSet.Validators)
|
||||
// It returns nil values if index < 0 or
|
||||
// index >= len(ValidatorSet.Validators)
|
||||
func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator) {
|
||||
if index >= len(valSet.Validators) {
|
||||
if index < 0 || index >= len(valSet.Validators) {
|
||||
return nil, nil
|
||||
}
|
||||
val = valSet.Validators[index]
|
||||
|
||||
@@ -17,6 +17,7 @@ var (
|
||||
ErrVoteInvalidValidatorAddress = errors.New("Invalid validator address")
|
||||
ErrVoteInvalidSignature = errors.New("Invalid signature")
|
||||
ErrVoteInvalidBlockHash = errors.New("Invalid block hash")
|
||||
ErrVoteNil = errors.New("Nil vote")
|
||||
)
|
||||
|
||||
type ErrVoteConflictingVotes struct {
|
||||
|
||||
@@ -123,6 +123,7 @@ func (voteSet *VoteSet) Size() int {
|
||||
// Conflicting votes return added=*, err=ErrVoteConflictingVotes.
|
||||
// NOTE: vote should not be mutated after adding.
|
||||
// NOTE: VoteSet must not be nil
|
||||
// NOTE: Vote must not be nil
|
||||
func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error) {
|
||||
if voteSet == nil {
|
||||
cmn.PanicSanity("AddVote() on nil VoteSet")
|
||||
@@ -135,6 +136,9 @@ func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error) {
|
||||
|
||||
// NOTE: Validates as much as possible before attempting to verify the signature.
|
||||
func (voteSet *VoteSet) addVote(vote *Vote) (added bool, err error) {
|
||||
if vote == nil {
|
||||
return false, ErrVoteNil
|
||||
}
|
||||
valIndex := vote.ValidatorIndex
|
||||
valAddr := vote.ValidatorAddress
|
||||
blockKey := vote.BlockID.Key()
|
||||
|
||||
Reference in New Issue
Block a user