From 5860869dd75a6f94d94a79c35349433020332404 Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 23 Sep 2020 14:15:26 +0300 Subject: [PATCH] check public key exists for EditCandidatePublicKeyData --- core/transaction/edit_candidate_public_key.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/transaction/edit_candidate_public_key.go b/core/transaction/edit_candidate_public_key.go index 6a8b9ecfc..b19440c51 100644 --- a/core/transaction/edit_candidate_public_key.go +++ b/core/transaction/edit_candidate_public_key.go @@ -56,6 +56,14 @@ func (data EditCandidatePublicKeyData) Run(tx *Transaction, context state.Interf } } + if checkState.Candidates().Exists(data.NewPubKey) { + return Response{ + Code: code.CandidateExists, + Log: fmt.Sprintf("Candidate with such public key (%s) already exists", data.NewPubKey.String()), + Info: EncodeError(code.NewCandidateExists(data.NewPubKey.String())), + } + } + commissionInBaseCoin := tx.CommissionInBaseCoin() commission := big.NewInt(0).Set(commissionInBaseCoin)