From 3e3781168dddca0f307ebfa4103c5a7d896a8f84 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 25 Jun 2020 10:55:45 +0300 Subject: [PATCH] rpc/client: do not query contract for account if it is in the wallet --- pkg/rpc/client/rpc.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index 39d9b6d36..d8c3874f7 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -8,6 +8,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" + "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/rpc/request" @@ -517,14 +518,18 @@ func (c *Client) AddNetworkFee(tx *transaction.Transaction, acc *wallet.Account) size += sizeDelta } for _, cosigner := range tx.Cosigners { - contract, err := c.GetContractState(cosigner.Account) - if err != nil { - return err + script := acc.Contract.Script + if !cosigner.Account.Equals(hash.Hash160(acc.Contract.Script)) { + contract, err := c.GetContractState(cosigner.Account) + if err != nil { + return err + } + if contract == nil { + continue + } + script = contract.Script } - if contract == nil { - continue - } - netFee, sizeDelta := core.CalculateNetworkFee(contract.Script) + netFee, sizeDelta := core.CalculateNetworkFee(script) tx.NetworkFee += netFee size += sizeDelta }