forked from TrueCloudLab/frostfs-node
[#66] node: Replace interface{} with any
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
3d873237d5
commit
cb5468abb8
67 changed files with 135 additions and 135 deletions
|
@ -179,7 +179,7 @@ func wrapFrostFSError(err error) error {
|
|||
|
||||
// Invoke invokes contract method by sending transaction into blockchain.
|
||||
// Supported args types: int64, string, util.Uint160, []byte and bool.
|
||||
func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...interface{}) error {
|
||||
func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) error {
|
||||
c.switchLock.RLock()
|
||||
defer c.switchLock.RUnlock()
|
||||
|
||||
|
@ -202,7 +202,7 @@ func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string,
|
|||
|
||||
// TestInvoke invokes contract method locally in neo-go node. This method should
|
||||
// be used to read data from smart-contract.
|
||||
func (c *Client) TestInvoke(contract util.Uint160, method string, args ...interface{}) (res []stackitem.Item, err error) {
|
||||
func (c *Client) TestInvoke(contract util.Uint160, method string, args ...any) (res []stackitem.Item, err error) {
|
||||
c.switchLock.RLock()
|
||||
defer c.switchLock.RUnlock()
|
||||
|
||||
|
@ -384,7 +384,7 @@ func (c *Client) roleList(r noderoles.Role) (keys.PublicKeys, error) {
|
|||
// tries to resolve sc.Parameter from the arg.
|
||||
//
|
||||
// Wraps any error to frostfsError.
|
||||
func toStackParameter(value interface{}) (sc.Parameter, error) {
|
||||
func toStackParameter(value any) (sc.Parameter, error) {
|
||||
var result = sc.Parameter{
|
||||
Value: value,
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
|
||||
func TestToStackParameter(t *testing.T) {
|
||||
items := []struct {
|
||||
value interface{}
|
||||
value any
|
||||
expType sc.ParamType
|
||||
expVal interface{}
|
||||
expVal any
|
||||
}{
|
||||
{
|
||||
value: []byte{1, 2, 3},
|
||||
|
|
|
@ -191,7 +191,7 @@ func (c *Client) readBoolConfig(key string) (bool, error) {
|
|||
type SetConfigPrm struct {
|
||||
id []byte
|
||||
key []byte
|
||||
value interface{}
|
||||
value any
|
||||
|
||||
client.InvokePrmOptional
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ func (s *SetConfigPrm) SetKey(key []byte) {
|
|||
}
|
||||
|
||||
// SetValue sets value of the config value.
|
||||
func (s *SetConfigPrm) SetValue(value interface{}) {
|
||||
func (s *SetConfigPrm) SetValue(value any) {
|
||||
s.value = value
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ var ErrConfigNotFound = errors.New("config value not found")
|
|||
// method of FrostFS Netmap contract.
|
||||
//
|
||||
// Returns ErrConfigNotFound if config key is not found in the contract.
|
||||
func (c *Client) config(key []byte, assert func(stackitem.Item) (interface{}, error)) (interface{}, error) {
|
||||
func (c *Client) config(key []byte, assert func(stackitem.Item) (any, error)) (any, error) {
|
||||
prm := client.TestInvokePrm{}
|
||||
prm.SetMethod(configMethod)
|
||||
prm.SetArgs(key)
|
||||
|
@ -383,17 +383,17 @@ func (c *Client) config(key []byte, assert func(stackitem.Item) (interface{}, er
|
|||
}
|
||||
|
||||
// IntegerAssert converts stack item to int64.
|
||||
func IntegerAssert(item stackitem.Item) (interface{}, error) {
|
||||
func IntegerAssert(item stackitem.Item) (any, error) {
|
||||
return client.IntFromStackItem(item)
|
||||
}
|
||||
|
||||
// StringAssert converts stack item to string.
|
||||
func StringAssert(item stackitem.Item) (interface{}, error) {
|
||||
func StringAssert(item stackitem.Item) (any, error) {
|
||||
return client.StringFromStackItem(item)
|
||||
}
|
||||
|
||||
// BoolAssert converts stack item to bool.
|
||||
func BoolAssert(item stackitem.Item) (interface{}, error) {
|
||||
func BoolAssert(item stackitem.Item) (any, error) {
|
||||
return client.BoolFromStackItem(item)
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ func (c *Client) depositNotary(amount fixedn.Fixed8, till int64) (res util.Uint2
|
|||
c.accAddr,
|
||||
c.notary.notary,
|
||||
big.NewInt(int64(amount)),
|
||||
[]interface{}{c.acc.PrivateKey().GetScriptHash(), till})
|
||||
[]any{c.acc.PrivateKey().GetScriptHash(), till})
|
||||
if err != nil {
|
||||
if !errors.Is(err, neorpc.ErrAlreadyExists) {
|
||||
return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err)
|
||||
|
@ -354,7 +354,7 @@ func (c *Client) UpdateNeoFSAlphabetList(prm UpdateAlphabetListPrm) error {
|
|||
// it fallbacks to a simple `Invoke()`.
|
||||
//
|
||||
// `nonce` and `vub` are used only if notary is enabled.
|
||||
func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...interface{}) error {
|
||||
func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) error {
|
||||
c.switchLock.RLock()
|
||||
defer c.switchLock.RUnlock()
|
||||
|
||||
|
@ -374,7 +374,7 @@ func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce ui
|
|||
// not expected to be signed by the current node.
|
||||
//
|
||||
// Considered to be used by non-IR nodes.
|
||||
func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8, method string, args ...interface{}) error {
|
||||
func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) error {
|
||||
c.switchLock.RLock()
|
||||
defer c.switchLock.RUnlock()
|
||||
|
||||
|
@ -440,12 +440,12 @@ func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) notaryInvokeAsCommittee(method string, nonce, vub uint32, args ...interface{}) error {
|
||||
func (c *Client) notaryInvokeAsCommittee(method string, nonce, vub uint32, args ...any) error {
|
||||
designate := c.GetDesignateHash()
|
||||
return c.notaryInvoke(true, true, designate, nonce, &vub, method, args...)
|
||||
}
|
||||
|
||||
func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint160, nonce uint32, vub *uint32, method string, args ...interface{}) error {
|
||||
func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint160, nonce uint32, vub *uint32, method string, args ...any) error {
|
||||
alphabetList, err := c.notary.alphabetSource() // prepare arguments for test invocation
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -750,7 +750,7 @@ func (c *Client) depositExpirationOf() (int64, error) {
|
|||
return currentTillBig.Int64(), nil
|
||||
}
|
||||
|
||||
func invocationParams(args ...interface{}) ([]sc.Parameter, error) {
|
||||
func invocationParams(args ...any) ([]sc.Parameter, error) {
|
||||
params := make([]sc.Parameter, 0, len(args))
|
||||
|
||||
for i := range args {
|
||||
|
|
|
@ -151,7 +151,7 @@ func (s StaticClient) Invoke(prm InvokePrm) error {
|
|||
// TestInvokePrm groups parameters of the TestInvoke operation.
|
||||
type TestInvokePrm struct {
|
||||
method string
|
||||
args []interface{}
|
||||
args []any
|
||||
}
|
||||
|
||||
// SetMethod sets method of the contract to call.
|
||||
|
@ -160,7 +160,7 @@ func (ti *TestInvokePrm) SetMethod(method string) {
|
|||
}
|
||||
|
||||
// SetArgs sets arguments of the contact call.
|
||||
func (ti *TestInvokePrm) SetArgs(args ...interface{}) {
|
||||
func (ti *TestInvokePrm) SetArgs(args ...any) {
|
||||
ti.args = args
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ type ManageAdminsRes struct{}
|
|||
func (x Client) ManageAdmins(prm ManageAdminsPrm) (*ManageAdminsPrm, error) {
|
||||
var method string
|
||||
|
||||
args := make([]interface{}, 1, 3)
|
||||
args := make([]any, 1, 3)
|
||||
args[0] = prm.subnet
|
||||
|
||||
if prm.client {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
// UserAllowedPrm groups parameters of UserAllowed method of Subnet contract.
|
||||
type UserAllowedPrm struct {
|
||||
args [2]interface{}
|
||||
args [2]any
|
||||
}
|
||||
|
||||
// SetID sets identifier of the subnet in a binary FrostFS API protocol format.
|
||||
|
@ -64,7 +64,7 @@ type ManageClientsPrm struct {
|
|||
// remove or add client
|
||||
rm bool
|
||||
|
||||
args [3]interface{}
|
||||
args [3]any
|
||||
}
|
||||
|
||||
// SetRemove marks client to be removed. By default, client is added.
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
type DeletePrm struct {
|
||||
cliPrm client.InvokePrm
|
||||
|
||||
args [1]interface{}
|
||||
args [1]any
|
||||
}
|
||||
|
||||
// SetTxHash sets hash of the transaction which spawned the notification.
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
// GetPrm groups parameters of Get method of Subnet contract.
|
||||
type GetPrm struct {
|
||||
args [1]interface{}
|
||||
args [1]any
|
||||
}
|
||||
|
||||
// SetID sets identifier of the subnet to be read in a binary FrostFS API protocol format.
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
type NodeAllowedPrm struct {
|
||||
cliPrm client.TestInvokePrm
|
||||
|
||||
args [2]interface{}
|
||||
args [2]any
|
||||
}
|
||||
|
||||
// SetID sets identifier of the subnet of the node in a binary FrostFS API protocol format.
|
||||
|
|
|
@ -9,7 +9,7 @@ type ManageNodesPrm struct {
|
|||
// remove or add node
|
||||
rm bool
|
||||
|
||||
args [2]interface{}
|
||||
args [2]any
|
||||
}
|
||||
|
||||
// SetRemove marks node to be removed. By default, node is added.
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
type PutPrm struct {
|
||||
cliPrm client.InvokePrm
|
||||
|
||||
args [3]interface{}
|
||||
args [3]any
|
||||
}
|
||||
|
||||
// SetTxHash sets hash of the transaction which spawned the notification.
|
||||
|
|
|
@ -341,7 +341,7 @@ func TestPrepare_CorrectNR(t *testing.T) {
|
|||
tests := []struct {
|
||||
hash util.Uint160
|
||||
method string
|
||||
args []interface{}
|
||||
args []any
|
||||
}{
|
||||
{
|
||||
scriptHash,
|
||||
|
@ -351,10 +351,10 @@ func TestPrepare_CorrectNR(t *testing.T) {
|
|||
{
|
||||
scriptHash,
|
||||
"test2",
|
||||
[]interface{}{
|
||||
[]any{
|
||||
int64(4),
|
||||
"test",
|
||||
[]interface{}{
|
||||
[]any{
|
||||
int64(4),
|
||||
false,
|
||||
true,
|
||||
|
@ -416,7 +416,7 @@ func alphaKeysSource() client.AlphabetKeys {
|
|||
}
|
||||
}
|
||||
|
||||
func script(hash util.Uint160, method string, args ...interface{}) []byte {
|
||||
func script(hash util.Uint160, method string, args ...any) []byte {
|
||||
bw := io.NewBufBinWriter()
|
||||
|
||||
if len(args) > 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue