Browse Source

fix validator_set add() bug

pull/39/head
Jae Kwon 10 years ago
parent
commit
b3b6a24317
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      state/validator_set.go

+ 4
- 2
state/validator_set.go View File

@ -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 = append(newValidators, valSet.Validators[idx:]...)
newValidators := make([]*Validator, len(valSet.Validators)+1)
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


Loading…
Cancel
Save