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:
Roman Khimov 2020-02-12 18:16:57 +03:00
parent 8310b76d28
commit 2ff7ceb8cf

View file

@ -714,15 +714,14 @@ func processAccountStateDescriptor(descriptor *transaction.StateDescriptor, dao
return err return err
} }
account.Votes = votes account.Votes = votes
if votes.Len() != len(account.Votes) { for _, vote := range account.Votes {
for _, vote := range votes { validatorState, err := dao.GetValidatorStateOrNew(vote)
validator, err := dao.GetValidatorStateOrNew(vote) if err != nil {
if err != nil { return err
return err }
} validatorState.Votes += balance
if err := dao.PutValidatorState(validator); err != nil { if err = dao.PutValidatorState(validatorState); err != nil {
return err return err
}
} }
} }
return dao.PutAccountState(account) return dao.PutAccountState(account)