From 2ff7ceb8cf6cb46d9a3d7bdc3bcc0d6f1e9e9ef2 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 12 Feb 2020 18:16:57 +0300 Subject: [PATCH] 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. --- pkg/core/blockchain.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index c723f2e50..73b293564 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -714,15 +714,14 @@ 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) - if err != nil { - return err - } - if err := dao.PutValidatorState(validator); err != nil { - return err - } + for _, vote := range account.Votes { + validatorState, err := dao.GetValidatorStateOrNew(vote) + if err != nil { + return err + } + validatorState.Votes += balance + if err = dao.PutValidatorState(validatorState); err != nil { + return err } } return dao.PutAccountState(account)