forked from TrueCloudLab/frostfs-node
[#746] morph/client: Don't cache GAS contract address on NeoFS-side
Caching is performed inside `GetNativeContractHash` method of neo-go client, so the additional cache level is redundant. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>support/v0.27
parent
0502abc3e0
commit
81722c373b
|
@ -587,7 +587,8 @@ NeoFS-API v2.0 support and updated brand-new storage node application.
|
||||||
|
|
||||||
First public review release.
|
First public review release.
|
||||||
|
|
||||||
[Unreleased]: https://github.com/nspcc-dev/neofs-node/compare/v0.23.1...master
|
[Unreleased]: https://github.com/nspcc-dev/neofs-node/compare/v0.24.0...master
|
||||||
|
[0.24.0]: https://github.com/nspcc-dev/neofs-node/compare/v0.23.1...v0.24.0
|
||||||
[0.23.1]: https://github.com/nspcc-dev/neofs-node/compare/v0.23.0...v0.23.1
|
[0.23.1]: https://github.com/nspcc-dev/neofs-node/compare/v0.23.0...v0.23.1
|
||||||
[0.23.0]: https://github.com/nspcc-dev/neofs-node/compare/v0.22.3...v0.23.0
|
[0.23.0]: https://github.com/nspcc-dev/neofs-node/compare/v0.22.3...v0.23.0
|
||||||
[0.22.3]: https://github.com/nspcc-dev/neofs-node/compare/v0.22.2...v0.22.3
|
[0.22.3]: https://github.com/nspcc-dev/neofs-node/compare/v0.22.2...v0.22.3
|
||||||
|
|
|
@ -47,8 +47,6 @@ type singleClient struct {
|
||||||
|
|
||||||
acc *wallet.Account // neo account
|
acc *wallet.Account // neo account
|
||||||
|
|
||||||
gas util.Uint160 // native gas script-hash
|
|
||||||
|
|
||||||
waitInterval time.Duration
|
waitInterval time.Duration
|
||||||
|
|
||||||
signer *transaction.Signer
|
signer *transaction.Signer
|
||||||
|
@ -215,7 +213,12 @@ func (c *Client) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
txHash, err := c.client.TransferNEP17(c.acc, receiver, c.gas, int64(amount), 0, nil, nil)
|
gas, err := c.client.GetNativeContractHash(nativenames.Gas)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
txHash, err := c.client.TransferNEP17(c.acc, receiver, gas, int64(amount), 0, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -281,7 +284,12 @@ func (c *Client) GasBalance() (res int64, err error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.client.NEP17BalanceOf(c.gas, c.acc.PrivateKey().GetScriptHash())
|
gas, err := c.client.GetNativeContractHash(nativenames.Gas)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.client.NEP17BalanceOf(gas, c.acc.PrivateKey().GetScriptHash())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Committee returns keys of chain committee from neo native contract.
|
// Committee returns keys of chain committee from neo native contract.
|
||||||
|
|
|
@ -3,7 +3,6 @@ package client
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -37,17 +36,11 @@ func (x *multiClient) createForAddress(addr string) (*Client, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
gas, err := cli.GetNativeContractHash(nativenames.Gas)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
c := &Client{
|
c := &Client{
|
||||||
singleClient: &singleClient{
|
singleClient: &singleClient{
|
||||||
logger: x.cfg.logger,
|
logger: x.cfg.logger,
|
||||||
client: cli,
|
client: cli,
|
||||||
acc: x.account,
|
acc: x.account,
|
||||||
gas: gas,
|
|
||||||
waitInterval: x.cfg.waitInterval,
|
waitInterval: x.cfg.waitInterval,
|
||||||
signer: x.cfg.signer,
|
signer: x.cfg.signer,
|
||||||
notary: x.sharedNotary,
|
notary: x.sharedNotary,
|
||||||
|
|
|
@ -151,10 +151,15 @@ func (c *Client) DepositNotary(amount fixedn.Fixed8, delta uint32) (res util.Uin
|
||||||
return util.Uint256{}, fmt.Errorf("can't get blockchain height: %w", err)
|
return util.Uint256{}, fmt.Errorf("can't get blockchain height: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gas, err := c.client.GetNativeContractHash(nativenames.Gas)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, err
|
||||||
|
}
|
||||||
|
|
||||||
txHash, err := c.client.TransferNEP17(
|
txHash, err := c.client.TransferNEP17(
|
||||||
c.acc,
|
c.acc,
|
||||||
c.notary.notary,
|
c.notary.notary,
|
||||||
c.gas,
|
gas,
|
||||||
int64(amount),
|
int64(amount),
|
||||||
0,
|
0,
|
||||||
[]interface{}{c.acc.PrivateKey().GetScriptHash(), int64(bc + delta)},
|
[]interface{}{c.acc.PrivateKey().GetScriptHash(), int64(bc + delta)},
|
||||||
|
|
Loading…
Reference in New Issue