mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 12:11:58 +00:00
fix validator_set add() bug
This commit is contained in:
@@ -144,8 +144,10 @@ func (valSet *ValidatorSet) Add(val *Validator) (added bool) {
|
|||||||
} else if bytes.Compare(valSet.Validators[idx].Address, val.Address) == 0 {
|
} else if bytes.Compare(valSet.Validators[idx].Address, val.Address) == 0 {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
newValidators := append(valSet.Validators[:idx], val)
|
newValidators := make([]*Validator, len(valSet.Validators)+1)
|
||||||
newValidators = append(newValidators, valSet.Validators[idx:]...)
|
copy(newValidators[:idx], valSet.Validators[:idx])
|
||||||
|
newValidators[idx] = val
|
||||||
|
copy(newValidators[idx+1:], valSet.Validators[idx:])
|
||||||
valSet.Validators = newValidators
|
valSet.Validators = newValidators
|
||||||
// Invalidate cache
|
// Invalidate cache
|
||||||
valSet.proposer = nil
|
valSet.proposer = nil
|
||||||
|
Reference in New Issue
Block a user