rpc/client: do not query contract for account if it is in the wallet

This commit is contained in:
Evgenii Stratonikov 2020-06-25 10:55:45 +03:00
parent b599b395e8
commit 3e3781168d

View file

@ -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,6 +518,8 @@ func (c *Client) AddNetworkFee(tx *transaction.Transaction, acc *wallet.Account)
size += sizeDelta
}
for _, cosigner := range tx.Cosigners {
script := acc.Contract.Script
if !cosigner.Account.Equals(hash.Hash160(acc.Contract.Script)) {
contract, err := c.GetContractState(cosigner.Account)
if err != nil {
return err
@ -524,7 +527,9 @@ func (c *Client) AddNetworkFee(tx *transaction.Transaction, acc *wallet.Account)
if contract == nil {
continue
}
netFee, sizeDelta := core.CalculateNetworkFee(contract.Script)
script = contract.Script
}
netFee, sizeDelta := core.CalculateNetworkFee(script)
tx.NetworkFee += netFee
size += sizeDelta
}