core: properly update validator votes for Account descriptor
ValidatorsCount is not implemented yet, but we need to update validators properly, adding account's vote to their votes count.
This commit is contained in:
parent
8310b76d28
commit
2ff7ceb8cf
1 changed files with 8 additions and 9 deletions
|
@ -714,17 +714,16 @@ func processAccountStateDescriptor(descriptor *transaction.StateDescriptor, dao
|
|||
return err
|
||||
}
|
||||
account.Votes = votes
|
||||
if votes.Len() != len(account.Votes) {
|
||||
for _, vote := range votes {
|
||||
validator, err := dao.GetValidatorStateOrNew(vote)
|
||||
for _, vote := range account.Votes {
|
||||
validatorState, err := dao.GetValidatorStateOrNew(vote)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := dao.PutValidatorState(validator); err != nil {
|
||||
validatorState.Votes += balance
|
||||
if err = dao.PutValidatorState(validatorState); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return dao.PutAccountState(account)
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue