From cb5468abb8dc709d1715a56bfd7bd345d7a2c541 Mon Sep 17 00:00:00 2001 From: Alejandro Lopez Date: Tue, 21 Feb 2023 14:42:45 +0300 Subject: [PATCH] [#66] node: Replace interface{} with any Signed-off-by: Alejandro Lopez --- .../internal/modules/morph/config.go | 2 +- .../modules/morph/initialize_deploy.go | 18 +++++++++--------- .../internal/modules/morph/initialize_nns.go | 2 +- .../internal/modules/morph/initialize_roles.go | 2 +- .../internal/modules/morph/local_client.go | 6 +++--- .../internal/modules/morph/notary.go | 2 +- .../internal/modules/morph/subnet.go | 10 +++++----- cmd/frostfs-cli/internal/common/verbose.go | 2 +- cmd/frostfs-cli/modules/control/shards_list.go | 4 ++-- cmd/frostfs-cli/modules/storagegroup/put.go | 2 +- cmd/frostfs-node/config/calls.go | 2 +- cmd/frostfs-node/reputation/common/util.go | 2 +- .../processors/settlement/processor.go | 2 +- pkg/local_object_storage/engine/delete_test.go | 2 +- pkg/local_object_storage/internal/log/log.go | 2 +- pkg/morph/client/client.go | 6 +++--- pkg/morph/client/client_test.go | 4 ++-- pkg/morph/client/netmap/config.go | 12 ++++++------ pkg/morph/client/notary.go | 12 ++++++------ pkg/morph/client/static.go | 4 ++-- pkg/morph/client/subnet/admin.go | 2 +- pkg/morph/client/subnet/clients.go | 4 ++-- pkg/morph/client/subnet/delete.go | 2 +- pkg/morph/client/subnet/get.go | 2 +- pkg/morph/client/subnet/node.go | 2 +- pkg/morph/client/subnet/nodes.go | 2 +- pkg/morph/client/subnet/put.go | 2 +- pkg/morph/event/notary_preparator_test.go | 8 ++++---- pkg/services/accounting/response.go | 2 +- pkg/services/accounting/sign.go | 2 +- .../announcement/load/controller/controller.go | 2 +- .../load/route/placement/builder.go | 2 +- .../announcement/load/route/router.go | 2 +- pkg/services/container/response.go | 14 +++++++------- pkg/services/container/sign.go | 14 +++++++------- pkg/services/control/ir/server/server.go | 2 +- pkg/services/netmap/response.go | 6 +++--- pkg/services/netmap/sign.go | 6 +++--- pkg/services/notificator/service.go | 2 +- pkg/services/object/acl/acl.go | 4 ++-- pkg/services/object/acl/v2/request.go | 6 +++--- pkg/services/object/acl/v2/service.go | 2 +- pkg/services/object/acl/v2/types.go | 2 +- pkg/services/object/acl/v2/util.go | 2 +- pkg/services/object/put/pool.go | 2 +- pkg/services/object/response.go | 8 ++++---- pkg/services/object/sign.go | 8 ++++---- pkg/services/object/util/chain.go | 2 +- .../object_manager/tombstone/constructor.go | 2 +- .../reputation/common/router/router.go | 2 +- .../eigentrust/calculator/calculator.go | 2 +- .../eigentrust/controller/controller.go | 2 +- .../reputation/eigentrust/routes/builder.go | 2 +- .../reputation/local/controller/controller.go | 2 +- .../reputation/local/routes/builder.go | 2 +- pkg/services/reputation/rpc/response.go | 4 ++-- pkg/services/reputation/rpc/sign.go | 4 ++-- pkg/services/session/response.go | 2 +- pkg/services/session/sign.go | 2 +- pkg/services/util/response/client_stream.go | 2 +- pkg/services/util/response/unary.go | 2 +- pkg/services/util/sign.go | 14 +++++++------- pkg/util/http/server.go | 6 +++--- pkg/util/locode/db/airports/db.go | 2 +- pkg/util/locode/db/boltdb/db.go | 2 +- pkg/util/locode/db/continents/geojson/db.go | 2 +- pkg/util/locode/table/csv/table.go | 2 +- 67 files changed, 135 insertions(+), 135 deletions(-) diff --git a/cmd/frostfs-adm/internal/modules/morph/config.go b/cmd/frostfs-adm/internal/modules/morph/config.go index 20ac0bc3..4a653cb6 100644 --- a/cmd/frostfs-adm/internal/modules/morph/config.go +++ b/cmd/frostfs-adm/internal/modules/morph/config.go @@ -140,7 +140,7 @@ func setConfigCmd(cmd *cobra.Command, args []string) error { return wCtx.awaitTx() } -func parseConfigPair(kvStr string, force bool) (key string, val interface{}, err error) { +func parseConfigPair(kvStr string, force bool) (key string, val any, err error) { kv := strings.SplitN(kvStr, "=", 2) if len(kv) != 2 { return "", nil, fmt.Errorf("invalid parameter format: must be 'key=val', got: %s", kvStr) diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go b/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go index 27016ce5..d12b2a52 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_deploy.go @@ -167,7 +167,7 @@ func (c *initializeContext) updateContracts() error { w := io2.NewBufBinWriter() - var keysParam []interface{} + var keysParam []any // Update script size for a single-node committee is close to the maximum allowed size of 65535. // Because of this we want to reuse alphabet contract NEF and manifest for different updates. @@ -299,7 +299,7 @@ func (c *initializeContext) updateContracts() error { func (c *initializeContext) deployContracts() error { alphaCs := c.getContract(alphabetContract) - var keysParam []interface{} + var keysParam []any baseGroups := alphaCs.Manifest.Groups @@ -510,12 +510,12 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*contr return m, nil } -func getContractDeployParameters(cs *contractState, deployData []interface{}) []interface{} { - return []interface{}{cs.RawNEF, cs.RawManifest, deployData} +func getContractDeployParameters(cs *contractState, deployData []any) []any { + return []any{cs.RawNEF, cs.RawManifest, deployData} } -func (c *initializeContext) getContractDeployData(ctrName string, keysParam []interface{}) []interface{} { - items := make([]interface{}, 1, 6) +func (c *initializeContext) getContractDeployData(ctrName string, keysParam []any) []any { + items := make([]any, 1, 6) items[0] = false // notaryDisabled is false switch ctrName { @@ -551,7 +551,7 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []in c.Contracts[netmapContract].Hash, c.Contracts[containerContract].Hash) case netmapContract: - configParam := []interface{}{ + configParam := []any{ netmapEpochKey, viper.GetInt64(epochDurationInitFlag), netmapMaxObjectSizeKey, viper.GetInt64(maxObjectSizeInitFlag), netmapAuditFeeKey, viper.GetInt64(auditFeeInitFlag), @@ -580,8 +580,8 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []in return items } -func (c *initializeContext) getAlphabetDeployItems(i, n int) []interface{} { - items := make([]interface{}, 6) +func (c *initializeContext) getAlphabetDeployItems(i, n int) []any { + items := make([]any, 6) items[0] = false items[1] = c.Contracts[netmapContract].Hash items[2] = c.Contracts[proxyContract].Hash diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go b/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go index 06b902b2..3c6d05a7 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go @@ -281,7 +281,7 @@ func nnsIsAvailable(c Client, nnsHash util.Uint160, name string) (bool, error) { case *rpcclient.Client: return ct.NNSIsAvailable(nnsHash, name) default: - b, err := unwrap.Bool(invokeFunction(c, nnsHash, "isAvailable", []interface{}{name}, nil)) + b, err := unwrap.Bool(invokeFunction(c, nnsHash, "isAvailable", []any{name}, nil)) if err != nil { return false, fmt.Errorf("`isAvailable`: invalid response: %w", err) } diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_roles.go b/cmd/frostfs-adm/internal/modules/morph/initialize_roles.go index 88415012..46466602 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_roles.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_roles.go @@ -16,7 +16,7 @@ func (c *initializeContext) setNotaryAndAlphabetNodes() error { return err } - var pubs []interface{} + var pubs []any for _, acc := range c.Accounts { pubs = append(pubs, acc.PrivateKey().PublicKey().Bytes()) } diff --git a/cmd/frostfs-adm/internal/modules/morph/local_client.go b/cmd/frostfs-adm/internal/modules/morph/local_client.go index e3d08d3f..94ccedb3 100644 --- a/cmd/frostfs-adm/internal/modules/morph/local_client.go +++ b/cmd/frostfs-adm/internal/modules/morph/local_client.go @@ -190,7 +190,7 @@ func (l *localClient) GetCommittee() (keys.PublicKeys, error) { func (l *localClient) InvokeFunction(h util.Uint160, method string, sPrm []smartcontract.Parameter, ss []transaction.Signer) (*result.Invoke, error) { var err error - pp := make([]interface{}, len(sPrm)) + pp := make([]any, len(sPrm)) for i, p := range sPrm { pp[i], err = smartcontract.ExpandParameterToEmitable(p) if err != nil { @@ -346,7 +346,7 @@ func getSigners(sender *wallet.Account, cosigners []rpcclient.SignerAccount) ([] } func (l *localClient) NEP17BalanceOf(h util.Uint160, acc util.Uint160) (int64, error) { - res, err := invokeFunction(l, h, "balanceOf", []interface{}{acc}, nil) + res, err := invokeFunction(l, h, "balanceOf", []any{acc}, nil) if err != nil { return 0, err } @@ -451,7 +451,7 @@ func (l *localClient) putTransactions() error { return l.bc.AddBlock(b) } -func invokeFunction(c Client, h util.Uint160, method string, parameters []interface{}, signers []transaction.Signer) (*result.Invoke, error) { +func invokeFunction(c Client, h util.Uint160, method string, parameters []any, signers []transaction.Signer) (*result.Invoke, error) { w := io.NewBufBinWriter() emit.Array(w.BinWriter, parameters...) emit.AppCallNoArgs(w.BinWriter, h, method, callflag.All) diff --git a/cmd/frostfs-adm/internal/modules/morph/notary.go b/cmd/frostfs-adm/internal/modules/morph/notary.go index 5c8bc8c1..47466563 100644 --- a/cmd/frostfs-adm/internal/modules/morph/notary.go +++ b/cmd/frostfs-adm/internal/modules/morph/notary.go @@ -111,7 +111,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error { accHash, notary.Hash, big.NewInt(int64(gasAmount)), - []interface{}{nil, int64(height) + till}, + []any{nil, int64(height) + till}, ) if err != nil { return fmt.Errorf("could not send tx: %w", err) diff --git a/cmd/frostfs-adm/internal/modules/morph/subnet.go b/cmd/frostfs-adm/internal/modules/morph/subnet.go index cb5f03ed..6b6def2e 100644 --- a/cmd/frostfs-adm/internal/modules/morph/subnet.go +++ b/cmd/frostfs-adm/internal/modules/morph/subnet.go @@ -340,7 +340,7 @@ func manageSubnetAdmins(cmd *cobra.Command, rm bool) error { } // prepare call parameters - prm := make([]interface{}, 0, 3) + prm := make([]any, 0, 3) prm = append(prm, id.Marshal()) var method string @@ -742,7 +742,7 @@ func init() { ) } -func testInvokeMethod(key keys.PrivateKey, method string, args ...interface{}) ([]stackitem.Item, error) { +func testInvokeMethod(key keys.PrivateKey, method string, args ...any) ([]stackitem.Item, error) { c, err := getN3Client(viper.GetViper()) if err != nil { return nil, fmt.Errorf("morph client creation: %w", err) @@ -780,7 +780,7 @@ func testInvokeMethod(key keys.PrivateKey, method string, args ...interface{}) ( return res.Stack, nil } -func invokeMethod(key keys.PrivateKey, tryNotary bool, method string, args ...interface{}) error { +func invokeMethod(key keys.PrivateKey, tryNotary bool, method string, args ...any) error { c, err := getN3Client(viper.GetViper()) if err != nil { return fmt.Errorf("morph client creation: %w", err) @@ -821,7 +821,7 @@ func invokeMethod(key keys.PrivateKey, tryNotary bool, method string, args ...in return nil } -func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...interface{}) error { +func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...any) error { nnsCs, err := c.GetContractStateByID(1) if err != nil { return fmt.Errorf("NNS contract resolving: %w", err) @@ -868,7 +868,7 @@ func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...inter return nil } -func invokeNotary(c Client, key keys.PrivateKey, method string, notaryHash util.Uint160, args ...interface{}) error { +func invokeNotary(c Client, key keys.PrivateKey, method string, notaryHash util.Uint160, args ...any) error { nnsCs, err := c.GetContractStateByID(1) if err != nil { return fmt.Errorf("NNS contract resolving: %w", err) diff --git a/cmd/frostfs-cli/internal/common/verbose.go b/cmd/frostfs-cli/internal/common/verbose.go index 39e99d2d..0d45b1dc 100644 --- a/cmd/frostfs-cli/internal/common/verbose.go +++ b/cmd/frostfs-cli/internal/common/verbose.go @@ -12,7 +12,7 @@ import ( ) // PrintVerbose prints to the stdout if the commonflags.Verbose flag is on. -func PrintVerbose(cmd *cobra.Command, format string, a ...interface{}) { +func PrintVerbose(cmd *cobra.Command, format string, a ...any) { if viper.GetBool(commonflags.Verbose) { cmd.Printf(format+"\n", a...) } diff --git a/cmd/frostfs-cli/modules/control/shards_list.go b/cmd/frostfs-cli/modules/control/shards_list.go index e9517f6a..8faf5f6e 100644 --- a/cmd/frostfs-cli/modules/control/shards_list.go +++ b/cmd/frostfs-cli/modules/control/shards_list.go @@ -58,9 +58,9 @@ func listShards(cmd *cobra.Command, _ []string) { } func prettyPrintShardsJSON(cmd *cobra.Command, ii []*control.ShardInfo) { - out := make([]map[string]interface{}, 0, len(ii)) + out := make([]map[string]any, 0, len(ii)) for _, i := range ii { - out = append(out, map[string]interface{}{ + out = append(out, map[string]any{ "shard_id": base58.Encode(i.Shard_ID), "mode": shardModeToString(i.GetMode()), "metabase": i.GetMetabasePath(), diff --git a/cmd/frostfs-cli/modules/storagegroup/put.go b/cmd/frostfs-cli/modules/storagegroup/put.go index 163f445f..d6bad729 100644 --- a/cmd/frostfs-cli/modules/storagegroup/put.go +++ b/cmd/frostfs-cli/modules/storagegroup/put.go @@ -127,7 +127,7 @@ type sgHeadReceiver struct { prm internalclient.HeadObjectPrm } -func (c sgHeadReceiver) Head(addr oid.Address) (interface{}, error) { +func (c sgHeadReceiver) Head(addr oid.Address) (any, error) { c.prm.SetAddress(addr) res, err := internalclient.HeadObject(c.prm) diff --git a/cmd/frostfs-node/config/calls.go b/cmd/frostfs-node/config/calls.go index 42ea7c67..6cf3baa0 100644 --- a/cmd/frostfs-node/config/calls.go +++ b/cmd/frostfs-node/config/calls.go @@ -37,7 +37,7 @@ func (x *Config) Sub(name string) *Config { // recommended. // // Returns nil if config is nil. -func (x *Config) Value(name string) interface{} { +func (x *Config) Value(name string) any { value := x.v.Get(strings.Join(append(x.path, name), separator)) if value != nil || x.defaultPath == nil { return value diff --git a/cmd/frostfs-node/reputation/common/util.go b/cmd/frostfs-node/reputation/common/util.go index c4943c24..f10ce2ae 100644 --- a/cmd/frostfs-node/reputation/common/util.go +++ b/cmd/frostfs-node/reputation/common/util.go @@ -50,6 +50,6 @@ func (*OnlyKeyRemoteServerInfo) ExternalAddresses() []string { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func PanicOnPrmValue(n string, v interface{}) { +func PanicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/innerring/processors/settlement/processor.go b/pkg/innerring/processors/settlement/processor.go index c5722f6e..e656e6f9 100644 --- a/pkg/innerring/processors/settlement/processor.go +++ b/pkg/innerring/processors/settlement/processor.go @@ -41,7 +41,7 @@ type ( } ) -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf("invalid parameter %s (%T):%v", n, v, v)) } diff --git a/pkg/local_object_storage/engine/delete_test.go b/pkg/local_object_storage/engine/delete_test.go index e62080b7..6aefde08 100644 --- a/pkg/local_object_storage/engine/delete_test.go +++ b/pkg/local_object_storage/engine/delete_test.go @@ -87,7 +87,7 @@ func TestDeleteBigObject(t *testing.T) { } } -func checkGetError(t *testing.T, e *StorageEngine, addr oid.Address, expected interface{}) { +func checkGetError(t *testing.T, e *StorageEngine, addr oid.Address, expected any) { var getPrm GetPrm getPrm.WithAddress(addr) diff --git a/pkg/local_object_storage/internal/log/log.go b/pkg/local_object_storage/internal/log/log.go index cd6df3f4..b8eff90f 100644 --- a/pkg/local_object_storage/internal/log/log.go +++ b/pkg/local_object_storage/internal/log/log.go @@ -16,7 +16,7 @@ func Write(logger *logger.Logger, fields ...zap.Field) { // AddressField returns logger's field for object address. // // Address should be type of *object.Address or string. -func AddressField(addr interface{}) zap.Field { +func AddressField(addr any) zap.Field { return zap.Any("address", addr) } diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index 473a09d7..fb43c4b2 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -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, } diff --git a/pkg/morph/client/client_test.go b/pkg/morph/client/client_test.go index 5239ffa1..a448c2cf 100644 --- a/pkg/morph/client/client_test.go +++ b/pkg/morph/client/client_test.go @@ -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}, diff --git a/pkg/morph/client/netmap/config.go b/pkg/morph/client/netmap/config.go index c75f147a..67ab436d 100644 --- a/pkg/morph/client/netmap/config.go +++ b/pkg/morph/client/netmap/config.go @@ -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) } diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 4331a3bb..30e55171 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -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 { diff --git a/pkg/morph/client/static.go b/pkg/morph/client/static.go index 207b97d0..afaf49f3 100644 --- a/pkg/morph/client/static.go +++ b/pkg/morph/client/static.go @@ -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 } diff --git a/pkg/morph/client/subnet/admin.go b/pkg/morph/client/subnet/admin.go index 72806d4a..28941253 100644 --- a/pkg/morph/client/subnet/admin.go +++ b/pkg/morph/client/subnet/admin.go @@ -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 { diff --git a/pkg/morph/client/subnet/clients.go b/pkg/morph/client/subnet/clients.go index 2855c0c8..9b6b47da 100644 --- a/pkg/morph/client/subnet/clients.go +++ b/pkg/morph/client/subnet/clients.go @@ -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. diff --git a/pkg/morph/client/subnet/delete.go b/pkg/morph/client/subnet/delete.go index 50dca9f5..d531be18 100644 --- a/pkg/morph/client/subnet/delete.go +++ b/pkg/morph/client/subnet/delete.go @@ -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. diff --git a/pkg/morph/client/subnet/get.go b/pkg/morph/client/subnet/get.go index cf3cc511..314188cf 100644 --- a/pkg/morph/client/subnet/get.go +++ b/pkg/morph/client/subnet/get.go @@ -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. diff --git a/pkg/morph/client/subnet/node.go b/pkg/morph/client/subnet/node.go index bdba593f..b878f5ac 100644 --- a/pkg/morph/client/subnet/node.go +++ b/pkg/morph/client/subnet/node.go @@ -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. diff --git a/pkg/morph/client/subnet/nodes.go b/pkg/morph/client/subnet/nodes.go index cc714fb7..cdbfab18 100644 --- a/pkg/morph/client/subnet/nodes.go +++ b/pkg/morph/client/subnet/nodes.go @@ -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. diff --git a/pkg/morph/client/subnet/put.go b/pkg/morph/client/subnet/put.go index ce0babcb..3df5d98a 100644 --- a/pkg/morph/client/subnet/put.go +++ b/pkg/morph/client/subnet/put.go @@ -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. diff --git a/pkg/morph/event/notary_preparator_test.go b/pkg/morph/event/notary_preparator_test.go index 6e9b732a..397fcefd 100644 --- a/pkg/morph/event/notary_preparator_test.go +++ b/pkg/morph/event/notary_preparator_test.go @@ -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 { diff --git a/pkg/services/accounting/response.go b/pkg/services/accounting/response.go index d2d3d10e..970c18da 100644 --- a/pkg/services/accounting/response.go +++ b/pkg/services/accounting/response.go @@ -25,7 +25,7 @@ func NewResponseService(accSvc Server, respSvc *response.Service) Server { func (s *responseService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Balance(ctx, req.(*accounting.BalanceRequest)) }, ) diff --git a/pkg/services/accounting/sign.go b/pkg/services/accounting/sign.go index 2b5f6d42..998f6a76 100644 --- a/pkg/services/accounting/sign.go +++ b/pkg/services/accounting/sign.go @@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server { func (s *signService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Balance(ctx, req.(*accounting.BalanceRequest)) }, func() util.ResponseMessage { diff --git a/pkg/services/container/announcement/load/controller/controller.go b/pkg/services/container/announcement/load/controller/controller.go index 16c809ac..ef6dbade 100644 --- a/pkg/services/container/announcement/load/controller/controller.go +++ b/pkg/services/container/announcement/load/controller/controller.go @@ -57,7 +57,7 @@ type Controller struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/container/announcement/load/route/placement/builder.go b/pkg/services/container/announcement/load/route/placement/builder.go index 15fafb42..493b8972 100644 --- a/pkg/services/container/announcement/load/route/placement/builder.go +++ b/pkg/services/container/announcement/load/route/placement/builder.go @@ -27,7 +27,7 @@ type Builder struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/container/announcement/load/route/router.go b/pkg/services/container/announcement/load/route/router.go index 6f8dd5f1..8db3882d 100644 --- a/pkg/services/container/announcement/load/route/router.go +++ b/pkg/services/container/announcement/load/route/router.go @@ -51,7 +51,7 @@ type Router struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/container/response.go b/pkg/services/container/response.go index f29ebce9..37b1eee5 100644 --- a/pkg/services/container/response.go +++ b/pkg/services/container/response.go @@ -25,7 +25,7 @@ func NewResponseService(cnrSvc Server, respSvc *response.Service) Server { func (s *responseService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Put(ctx, req.(*container.PutRequest)) }, ) @@ -38,7 +38,7 @@ func (s *responseService) Put(ctx context.Context, req *container.PutRequest) (* func (s *responseService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Delete(ctx, req.(*container.DeleteRequest)) }, ) @@ -51,7 +51,7 @@ func (s *responseService) Delete(ctx context.Context, req *container.DeleteReque func (s *responseService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Get(ctx, req.(*container.GetRequest)) }, ) @@ -64,7 +64,7 @@ func (s *responseService) Get(ctx context.Context, req *container.GetRequest) (* func (s *responseService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.List(ctx, req.(*container.ListRequest)) }, ) @@ -77,7 +77,7 @@ func (s *responseService) List(ctx context.Context, req *container.ListRequest) func (s *responseService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest)) }, ) @@ -90,7 +90,7 @@ func (s *responseService) SetExtendedACL(ctx context.Context, req *container.Set func (s *responseService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest)) }, ) @@ -103,7 +103,7 @@ func (s *responseService) GetExtendedACL(ctx context.Context, req *container.Get func (s *responseService) AnnounceUsedSpace(ctx context.Context, req *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.AnnounceUsedSpace(ctx, req.(*container.AnnounceUsedSpaceRequest)) }, ) diff --git a/pkg/services/container/sign.go b/pkg/services/container/sign.go index 5aa9bbd7..fec2d327 100644 --- a/pkg/services/container/sign.go +++ b/pkg/services/container/sign.go @@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server { func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Put(ctx, req.(*container.PutRequest)) }, func() util.ResponseMessage { @@ -39,7 +39,7 @@ func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*cont func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Delete(ctx, req.(*container.DeleteRequest)) }, func() util.ResponseMessage { @@ -55,7 +55,7 @@ func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest) func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Get(ctx, req.(*container.GetRequest)) }, func() util.ResponseMessage { @@ -71,7 +71,7 @@ func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*cont func (s *signService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.List(ctx, req.(*container.ListRequest)) }, func() util.ResponseMessage { @@ -87,7 +87,7 @@ func (s *signService) List(ctx context.Context, req *container.ListRequest) (*co func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest)) }, func() util.ResponseMessage { @@ -103,7 +103,7 @@ func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExte func (s *signService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest)) }, func() util.ResponseMessage { @@ -119,7 +119,7 @@ func (s *signService) GetExtendedACL(ctx context.Context, req *container.GetExte func (s *signService) AnnounceUsedSpace(ctx context.Context, req *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.AnnounceUsedSpace(ctx, req.(*container.AnnounceUsedSpaceRequest)) }, func() util.ResponseMessage { diff --git a/pkg/services/control/ir/server/server.go b/pkg/services/control/ir/server/server.go index a232187a..c75c1504 100644 --- a/pkg/services/control/ir/server/server.go +++ b/pkg/services/control/ir/server/server.go @@ -15,7 +15,7 @@ type Server struct { allowedKeys [][]byte } -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { const invalidPrmValFmt = "invalid %s parameter (%T): %v" panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/netmap/response.go b/pkg/services/netmap/response.go index 067b19aa..14f6dcd0 100644 --- a/pkg/services/netmap/response.go +++ b/pkg/services/netmap/response.go @@ -25,7 +25,7 @@ func NewResponseService(nmSvc Server, respSvc *response.Service) Server { func (s *responseService) LocalNodeInfo(ctx context.Context, req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.LocalNodeInfo(ctx, req.(*netmap.LocalNodeInfoRequest)) }, ) @@ -38,7 +38,7 @@ func (s *responseService) LocalNodeInfo(ctx context.Context, req *netmap.LocalNo func (s *responseService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.NetworkInfo(ctx, req.(*netmap.NetworkInfoRequest)) }, ) @@ -51,7 +51,7 @@ func (s *responseService) NetworkInfo(ctx context.Context, req *netmap.NetworkIn func (s *responseService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest)) }, ) diff --git a/pkg/services/netmap/sign.go b/pkg/services/netmap/sign.go index 78894679..b2a935e4 100644 --- a/pkg/services/netmap/sign.go +++ b/pkg/services/netmap/sign.go @@ -25,7 +25,7 @@ func (s *signService) LocalNodeInfo( ctx context.Context, req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.LocalNodeInfo(ctx, req.(*netmap.LocalNodeInfoRequest)) }, func() util.ResponseMessage { @@ -41,7 +41,7 @@ func (s *signService) LocalNodeInfo( func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.NetworkInfo(ctx, req.(*netmap.NetworkInfoRequest)) }, func() util.ResponseMessage { @@ -57,7 +57,7 @@ func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRe func (s *signService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest)) }, func() util.ResponseMessage { diff --git a/pkg/services/notificator/service.go b/pkg/services/notificator/service.go index 1ccc1776..c44ce872 100644 --- a/pkg/services/notificator/service.go +++ b/pkg/services/notificator/service.go @@ -52,7 +52,7 @@ type Notificator struct { // Panics if any field of the passed Prm structure is not set/set // to nil. func New(prm *Prm) *Notificator { - panicOnNil := func(v interface{}, name string) { + panicOnNil := func(v any, name string) { if v == nil { panic(fmt.Sprintf("Notificator constructor: %s is nil\n", name)) } diff --git a/pkg/services/object/acl/acl.go b/pkg/services/object/acl/acl.go index 78e972ea..906708d4 100644 --- a/pkg/services/object/acl/acl.go +++ b/pkg/services/object/acl/acl.go @@ -71,7 +71,7 @@ var ( // NewChecker creates Checker. // Panics if at least one of the parameter is nil. func NewChecker(prm *CheckerPrm) *Checker { - panicOnNil := func(fieldName string, field interface{}) { + panicOnNil := func(fieldName string, field any) { if field == nil { panic(fmt.Sprintf("incorrect field %s (%T): %v", fieldName, field, field)) } @@ -118,7 +118,7 @@ func (c *Checker) StickyBitCheck(info v2.RequestInfo, owner user.ID) bool { } // CheckEACL is a main check function for extended ACL. -func (c *Checker) CheckEACL(msg interface{}, reqInfo v2.RequestInfo) error { +func (c *Checker) CheckEACL(msg any, reqInfo v2.RequestInfo) error { basicACL := reqInfo.BasicACL() if !basicACL.Extendable() { return nil diff --git a/pkg/services/object/acl/v2/request.go b/pkg/services/object/acl/v2/request.go index 2a708c3f..f74a0b3b 100644 --- a/pkg/services/object/acl/v2/request.go +++ b/pkg/services/object/acl/v2/request.go @@ -32,7 +32,7 @@ type RequestInfo struct { bearer *bearer.Token // bearer token of request - srcRequest interface{} + srcRequest any } func (r *RequestInfo) SetBasicACL(basicACL acl.Basic) { @@ -48,7 +48,7 @@ func (r *RequestInfo) SetSenderKey(senderKey []byte) { } // Request returns raw API request. -func (r RequestInfo) Request() interface{} { +func (r RequestInfo) Request() any { return r.srcRequest } @@ -103,7 +103,7 @@ type MetaWithToken struct { vheader *sessionV2.RequestVerificationHeader token *sessionSDK.Object bearer *bearer.Token - src interface{} + src any } // RequestOwner returns ownerID and its public key diff --git a/pkg/services/object/acl/v2/service.go b/pkg/services/object/acl/v2/service.go index 5432bcf9..62f7917f 100644 --- a/pkg/services/object/acl/v2/service.go +++ b/pkg/services/object/acl/v2/service.go @@ -86,7 +86,7 @@ func New(opts ...Option) Service { opts[i](cfg) } - panicOnNil := func(v interface{}, name string) { + panicOnNil := func(v any, name string) { if v == nil { panic(fmt.Sprintf("ACL service: %s is nil", name)) } diff --git a/pkg/services/object/acl/v2/types.go b/pkg/services/object/acl/v2/types.go index effacfbd..8c40cbe2 100644 --- a/pkg/services/object/acl/v2/types.go +++ b/pkg/services/object/acl/v2/types.go @@ -12,7 +12,7 @@ type ACLChecker interface { CheckBasicACL(RequestInfo) bool // CheckEACL must return non-nil error if request // doesn't pass extended ACL validation. - CheckEACL(interface{}, RequestInfo) error + CheckEACL(any, RequestInfo) error // StickyBitCheck must return true only if sticky bit // is disabled or enabled but request contains correct // owner field. diff --git a/pkg/services/object/acl/v2/util.go b/pkg/services/object/acl/v2/util.go index a7f1b63c..7afbd144 100644 --- a/pkg/services/object/acl/v2/util.go +++ b/pkg/services/object/acl/v2/util.go @@ -20,7 +20,7 @@ import ( var errMissingContainerID = errors.New("missing container ID") -func getContainerIDFromRequest(req interface{}) (cid.ID, error) { +func getContainerIDFromRequest(req any) (cid.ID, error) { var idV2 *refsV2.ContainerID var id cid.ID diff --git a/pkg/services/object/put/pool.go b/pkg/services/object/put/pool.go index 842d7674..70527322 100644 --- a/pkg/services/object/put/pool.go +++ b/pkg/services/object/put/pool.go @@ -7,7 +7,7 @@ import ( const defaultAllocSize = 1024 var putBytesPool = &sync.Pool{ - New: func() interface{} { return make([]byte, 0, defaultAllocSize) }, + New: func() any { return make([]byte, 0, defaultAllocSize) }, } func getPayload() []byte { diff --git a/pkg/services/object/response.go b/pkg/services/object/response.go index dc6d29b7..697ac778 100644 --- a/pkg/services/object/response.go +++ b/pkg/services/object/response.go @@ -80,7 +80,7 @@ func (s *ResponseService) Put(ctx context.Context) (PutObjectStream, error) { return &putStreamResponser{ stream: s.respSvc.CreateRequestStreamer( - func(req interface{}) error { + func(req any) error { return stream.Send(req.(*object.PutRequest)) }, func() (util.ResponseMessage, error) { @@ -92,7 +92,7 @@ func (s *ResponseService) Put(ctx context.Context) (PutObjectStream, error) { func (s *ResponseService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Head(ctx, req.(*object.HeadRequest)) }, ) @@ -118,7 +118,7 @@ func (s *ResponseService) Search(req *object.SearchRequest, stream SearchStream) func (s *ResponseService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Delete(ctx, req.(*object.DeleteRequest)) }, ) @@ -144,7 +144,7 @@ func (s *ResponseService) GetRange(req *object.GetRangeRequest, stream GetObject func (s *ResponseService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest)) }, ) diff --git a/pkg/services/object/sign.go b/pkg/services/object/sign.go index df0ff5a3..dbb116dd 100644 --- a/pkg/services/object/sign.go +++ b/pkg/services/object/sign.go @@ -91,7 +91,7 @@ func (s *SignService) Put(ctx context.Context) (PutObjectStream, error) { return &putStreamSigner{ stream: s.sigSvc.CreateRequestStreamer( - func(req interface{}) error { + func(req any) error { return stream.Send(req.(*object.PutRequest)) }, func() (util.ResponseMessage, error) { @@ -106,7 +106,7 @@ func (s *SignService) Put(ctx context.Context) (PutObjectStream, error) { func (s *SignService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Head(ctx, req.(*object.HeadRequest)) }, func() util.ResponseMessage { @@ -157,7 +157,7 @@ func (s *SignService) Search(req *object.SearchRequest, stream SearchStream) err func (s *SignService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Delete(ctx, req.(*object.DeleteRequest)) }, func() util.ResponseMessage { @@ -194,7 +194,7 @@ func (s *SignService) GetRange(req *object.GetRangeRequest, stream GetObjectRang func (s *SignService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest)) }, func() util.ResponseMessage { diff --git a/pkg/services/object/util/chain.go b/pkg/services/object/util/chain.go index 1cdd337d..b35d8445 100644 --- a/pkg/services/object/util/chain.go +++ b/pkg/services/object/util/chain.go @@ -14,7 +14,7 @@ type HeadReceiver interface { // Head must return one of: // * object header (*object.Object); // * structured information about split-chain (*object.SplitInfo). - Head(id oid.Address) (interface{}, error) + Head(id oid.Address) (any, error) } // SplitMemberHandler is a handler of next split-chain element. diff --git a/pkg/services/object_manager/tombstone/constructor.go b/pkg/services/object_manager/tombstone/constructor.go index cc0b664b..829ed9a1 100644 --- a/pkg/services/object_manager/tombstone/constructor.go +++ b/pkg/services/object_manager/tombstone/constructor.go @@ -40,7 +40,7 @@ func NewChecker(oo ...Option) *ExpirationChecker { o(cfg) } - panicOnNil := func(v interface{}, name string) { + panicOnNil := func(v any, name string) { if v == nil { panic(fmt.Sprintf("tombstone getter constructor: %s is nil", name)) } diff --git a/pkg/services/reputation/common/router/router.go b/pkg/services/reputation/common/router/router.go index f301deb4..2b3c0f26 100644 --- a/pkg/services/reputation/common/router/router.go +++ b/pkg/services/reputation/common/router/router.go @@ -52,7 +52,7 @@ type Router struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/reputation/eigentrust/calculator/calculator.go b/pkg/services/reputation/eigentrust/calculator/calculator.go index 9820fb3e..782cbed9 100644 --- a/pkg/services/reputation/eigentrust/calculator/calculator.go +++ b/pkg/services/reputation/eigentrust/calculator/calculator.go @@ -51,7 +51,7 @@ type Calculator struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/reputation/eigentrust/controller/controller.go b/pkg/services/reputation/eigentrust/controller/controller.go index 357a909b..17d58941 100644 --- a/pkg/services/reputation/eigentrust/controller/controller.go +++ b/pkg/services/reputation/eigentrust/controller/controller.go @@ -52,7 +52,7 @@ type Controller struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/reputation/eigentrust/routes/builder.go b/pkg/services/reputation/eigentrust/routes/builder.go index d5d49424..3410d173 100644 --- a/pkg/services/reputation/eigentrust/routes/builder.go +++ b/pkg/services/reputation/eigentrust/routes/builder.go @@ -34,7 +34,7 @@ type Builder struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/reputation/local/controller/controller.go b/pkg/services/reputation/local/controller/controller.go index a86fd484..c4c2ff4d 100644 --- a/pkg/services/reputation/local/controller/controller.go +++ b/pkg/services/reputation/local/controller/controller.go @@ -52,7 +52,7 @@ type Controller struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/reputation/local/routes/builder.go b/pkg/services/reputation/local/routes/builder.go index d5d49424..3410d173 100644 --- a/pkg/services/reputation/local/routes/builder.go +++ b/pkg/services/reputation/local/routes/builder.go @@ -34,7 +34,7 @@ type Builder struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/services/reputation/rpc/response.go b/pkg/services/reputation/rpc/response.go index bc636c70..dc1dba35 100644 --- a/pkg/services/reputation/rpc/response.go +++ b/pkg/services/reputation/rpc/response.go @@ -25,7 +25,7 @@ func NewResponseService(cnrSvc Server, respSvc *response.Service) Server { func (s *responseService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest)) }, ) @@ -38,7 +38,7 @@ func (s *responseService) AnnounceLocalTrust(ctx context.Context, req *reputatio func (s *responseService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest)) }, ) diff --git a/pkg/services/reputation/rpc/sign.go b/pkg/services/reputation/rpc/sign.go index e7fb0c60..054069a2 100644 --- a/pkg/services/reputation/rpc/sign.go +++ b/pkg/services/reputation/rpc/sign.go @@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server { func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest)) }, func() util.ResponseMessage { @@ -39,7 +39,7 @@ func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.An func (s *signService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest)) }, func() util.ResponseMessage { diff --git a/pkg/services/session/response.go b/pkg/services/session/response.go index 86de8825..0678c2de 100644 --- a/pkg/services/session/response.go +++ b/pkg/services/session/response.go @@ -25,7 +25,7 @@ func NewResponseService(ssSvc Server, respSvc *response.Service) Server { func (s *responseService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) { resp, err := s.respSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Create(ctx, req.(*session.CreateRequest)) }, ) diff --git a/pkg/services/session/sign.go b/pkg/services/session/sign.go index 7e873887..086b0c3c 100644 --- a/pkg/services/session/sign.go +++ b/pkg/services/session/sign.go @@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server { func (s *signService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) { resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, - func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + func(ctx context.Context, req any) (util.ResponseMessage, error) { return s.svc.Create(ctx, req.(*session.CreateRequest)) }, func() util.ResponseMessage { diff --git a/pkg/services/util/response/client_stream.go b/pkg/services/util/response/client_stream.go index c4a22171..8f0a8e03 100644 --- a/pkg/services/util/response/client_stream.go +++ b/pkg/services/util/response/client_stream.go @@ -17,7 +17,7 @@ type ClientMessageStreamer struct { } // Send calls send method of internal streamer. -func (s *ClientMessageStreamer) Send(req interface{}) error { +func (s *ClientMessageStreamer) Send(req any) error { if err := s.send(req); err != nil { return fmt.Errorf("(%T) could not send the request: %w", s, err) } diff --git a/pkg/services/util/response/unary.go b/pkg/services/util/response/unary.go index fcc74549..8dbe0a8a 100644 --- a/pkg/services/util/response/unary.go +++ b/pkg/services/util/response/unary.go @@ -8,7 +8,7 @@ import ( ) // HandleUnaryRequest call passes request to handler, sets response meta header values and returns it. -func (s *Service) HandleUnaryRequest(ctx context.Context, req interface{}, handler util.UnaryHandler) (util.ResponseMessage, error) { +func (s *Service) HandleUnaryRequest(ctx context.Context, req any, handler util.UnaryHandler) (util.ResponseMessage, error) { // process request resp, err := handler(ctx, req) if err != nil { diff --git a/pkg/services/util/sign.go b/pkg/services/util/sign.go index aebe025c..761eaee2 100644 --- a/pkg/services/util/sign.go +++ b/pkg/services/util/sign.go @@ -21,7 +21,7 @@ type ResponseMessage interface { SetMetaHeader(*session.ResponseMetaHeader) } -type UnaryHandler func(context.Context, interface{}) (ResponseMessage, error) +type UnaryHandler func(context.Context, any) (ResponseMessage, error) type SignService struct { key *ecdsa.PrivateKey @@ -29,7 +29,7 @@ type SignService struct { type ResponseMessageWriter func(ResponseMessage) error -type ServerStreamHandler func(context.Context, interface{}) (ResponseMessageReader, error) +type ServerStreamHandler func(context.Context, any) (ResponseMessageReader, error) type ResponseMessageReader func() (ResponseMessage, error) @@ -37,7 +37,7 @@ var ErrAbortStream = errors.New("abort message stream") type ResponseConstructor func() ResponseMessage -type RequestMessageWriter func(interface{}) error +type RequestMessageWriter func(any) error type ClientStreamCloser func() (ResponseMessage, error) @@ -61,7 +61,7 @@ func NewUnarySignService(key *ecdsa.PrivateKey) *SignService { } } -func (s *RequestMessageStreamer) Send(req interface{}) error { +func (s *RequestMessageStreamer) Send(req any) error { // req argument should be strengthen with type RequestMessage s.statusSupported = isStatusSupported(req.(RequestMessage)) // panic is OK here for now @@ -130,7 +130,7 @@ func (s *SignService) CreateRequestStreamer(sender RequestMessageWriter, closer } func (s *SignService) HandleServerStreamRequest( - req interface{}, + req any, respWriter ResponseMessageWriter, blankResp ResponseConstructor, respWriterCaller func(ResponseMessageWriter) error, @@ -172,7 +172,7 @@ func (s *SignService) HandleServerStreamRequest( return nil } -func (s *SignService) HandleUnaryRequest(ctx context.Context, req interface{}, handler UnaryHandler, blankResp ResponseConstructor) (ResponseMessage, error) { +func (s *SignService) HandleUnaryRequest(ctx context.Context, req any, handler UnaryHandler, blankResp ResponseConstructor) (ResponseMessage, error) { // handle protocol versions <=2.10 (API statuses was introduced in 2.11 only) // req argument should be strengthen with type RequestMessage @@ -233,7 +233,7 @@ func setStatusV2(resp ResponseMessage, err error) { // The signature error affects the result depending on the protocol version: // - if status return is supported, panics since we cannot return the failed status, because it will not be signed; // - otherwise, returns error in order to transport it directly. -func signResponse(key *ecdsa.PrivateKey, resp interface{}, statusSupported bool) error { +func signResponse(key *ecdsa.PrivateKey, resp any, statusSupported bool) error { err := signature.SignServiceMessage(key, resp) if err != nil { err = fmt.Errorf("could not sign response: %w", err) diff --git a/pkg/util/http/server.go b/pkg/util/http/server.go index 05a1f44c..923412a7 100644 --- a/pkg/util/http/server.go +++ b/pkg/util/http/server.go @@ -37,15 +37,15 @@ type Server struct { const invalidValFmt = "invalid %s %s (%T): %v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panicOnValue("parameter", n, v) } -func panicOnOptValue(n string, v interface{}) { +func panicOnOptValue(n string, v any) { panicOnValue("option", n, v) } -func panicOnValue(t, n string, v interface{}) { +func panicOnValue(t, n string, v any) { panic(fmt.Sprintf(invalidValFmt, t, n, v, v)) } diff --git a/pkg/util/locode/db/airports/db.go b/pkg/util/locode/db/airports/db.go index f14414cc..acfa3fd6 100644 --- a/pkg/util/locode/db/airports/db.go +++ b/pkg/util/locode/db/airports/db.go @@ -46,7 +46,7 @@ type pathMode struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/util/locode/db/boltdb/db.go b/pkg/util/locode/db/boltdb/db.go index 6a503e7e..3d09a797 100644 --- a/pkg/util/locode/db/boltdb/db.go +++ b/pkg/util/locode/db/boltdb/db.go @@ -43,7 +43,7 @@ type DB struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/util/locode/db/continents/geojson/db.go b/pkg/util/locode/db/continents/geojson/db.go index a5b8b76a..ee43bd81 100644 --- a/pkg/util/locode/db/continents/geojson/db.go +++ b/pkg/util/locode/db/continents/geojson/db.go @@ -35,7 +35,7 @@ type DB struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) } diff --git a/pkg/util/locode/table/csv/table.go b/pkg/util/locode/table/csv/table.go index ef5e996d..b84c2b70 100644 --- a/pkg/util/locode/table/csv/table.go +++ b/pkg/util/locode/table/csv/table.go @@ -43,7 +43,7 @@ type Table struct { const invalidPrmValFmt = "invalid parameter %s (%T):%v" -func panicOnPrmValue(n string, v interface{}) { +func panicOnPrmValue(n string, v any) { panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) }