diff --git a/pkg/innerring/processors/frostfs/handlers.go b/pkg/innerring/processors/frostfs/handlers.go index ab53d5c48..adb923b87 100644 --- a/pkg/innerring/processors/frostfs/handlers.go +++ b/pkg/innerring/processors/frostfs/handlers.go @@ -1,21 +1,24 @@ package frostfs import ( + "bytes" "encoding/hex" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event" frostfsEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/frostfs" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "go.uber.org/zap" + "golang.org/x/exp/slices" ) func (np *Processor) handleDeposit(ev event.Event) { deposit := ev.(frostfsEvent.Deposit) + depositIDBin := bytes.Clone(deposit.ID()) + slices.Reverse(depositIDBin) np.log.Info(logs.Notification, zap.String("type", "deposit"), - zap.String("id", hex.EncodeToString(slice.CopyReverse(deposit.ID())))) + zap.String("id", hex.EncodeToString(depositIDBin))) // send event to the worker pool @@ -31,9 +34,11 @@ func (np *Processor) handleDeposit(ev event.Event) { func (np *Processor) handleWithdraw(ev event.Event) { withdraw := ev.(frostfsEvent.Withdraw) + withdrawBin := bytes.Clone(withdraw.ID()) + slices.Reverse(withdrawBin) np.log.Info(logs.Notification, zap.String("type", "withdraw"), - zap.String("id", hex.EncodeToString(slice.CopyReverse(withdraw.ID())))) + zap.String("id", hex.EncodeToString(withdrawBin))) // send event to the worker pool diff --git a/pkg/local_object_storage/blobovnicza/get.go b/pkg/local_object_storage/blobovnicza/get.go index 3a613cfeb..9975e5e8c 100644 --- a/pkg/local_object_storage/blobovnicza/get.go +++ b/pkg/local_object_storage/blobovnicza/get.go @@ -1,13 +1,13 @@ package blobovnicza import ( + "bytes" "context" "errors" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "go.etcd.io/bbolt" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -63,7 +63,7 @@ func (b *Blobovnicza) Get(ctx context.Context, prm GetPrm) (GetRes, error) { return nil } - data = slice.Copy(data) + data = bytes.Clone(data) return errInterruptForEach }) diff --git a/pkg/local_object_storage/blobovnicza/iterate_test.go b/pkg/local_object_storage/blobovnicza/iterate_test.go index 90308723c..5db1e4165 100644 --- a/pkg/local_object_storage/blobovnicza/iterate_test.go +++ b/pkg/local_object_storage/blobovnicza/iterate_test.go @@ -1,13 +1,13 @@ package blobovnicza import ( + "bytes" "context" "errors" "path/filepath" "testing" oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "github.com/stretchr/testify/require" "go.etcd.io/bbolt" ) @@ -30,7 +30,7 @@ func TestBlobovniczaIterate(t *testing.T) { seen := make([][]byte, 0, 2) inc := func(e IterationElement) error { - seen = append(seen, slice.Copy(e.data)) + seen = append(seen, bytes.Clone(e.data)) return nil } diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go b/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go index 198e4741b..c89262343 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go @@ -1,6 +1,7 @@ package blobovniczatree import ( + "bytes" "context" "os" "path/filepath" @@ -10,7 +11,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/internal/blobstortest" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "github.com/stretchr/testify/require" ) @@ -37,7 +37,7 @@ func TestExistsInvalidStorageID(t *testing.T) { t.Run("valid but wrong storage id", func(t *testing.T) { // "0/X/Y" <-> "1/X/Y" - storageID := slice.Copy(putRes.StorageID) + storageID := bytes.Clone(putRes.StorageID) if storageID[0] == '0' { storageID[0]++ } else { diff --git a/pkg/local_object_storage/metabase/shard_id.go b/pkg/local_object_storage/metabase/shard_id.go index f60a4724d..c1ec8c67e 100644 --- a/pkg/local_object_storage/metabase/shard_id.go +++ b/pkg/local_object_storage/metabase/shard_id.go @@ -1,8 +1,9 @@ package meta import ( + "bytes" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "go.etcd.io/bbolt" ) @@ -25,7 +26,7 @@ func (db *DB) ReadShardID() ([]byte, error) { err := db.boltDB.View(func(tx *bbolt.Tx) error { b := tx.Bucket(shardInfoBucket) if b != nil { - id = slice.Copy(b.Get(shardIDKey)) + id = bytes.Clone(b.Get(shardIDKey)) } return nil }) diff --git a/pkg/local_object_storage/metabase/storage_id.go b/pkg/local_object_storage/metabase/storage_id.go index 0a64da856..ef6b44dfd 100644 --- a/pkg/local_object_storage/metabase/storage_id.go +++ b/pkg/local_object_storage/metabase/storage_id.go @@ -1,6 +1,7 @@ package meta import ( + "bytes" "context" "errors" "time" @@ -9,7 +10,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "go.etcd.io/bbolt" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -72,7 +72,7 @@ func (db *DB) storageID(tx *bbolt.Tx, addr oid.Address) ([]byte, error) { return nil, nil } - return slice.Copy(storageID), nil + return bytes.Clone(storageID), nil } // UpdateStorageIDPrm groups the parameters of UpdateStorageID operation. diff --git a/pkg/local_object_storage/shard/range_test.go b/pkg/local_object_storage/shard/range_test.go index a8bc83307..098a584ad 100644 --- a/pkg/local_object_storage/shard/range_test.go +++ b/pkg/local_object_storage/shard/range_test.go @@ -1,6 +1,7 @@ package shard import ( + "bytes" "context" "math" "path/filepath" @@ -16,7 +17,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "github.com/stretchr/testify/require" ) @@ -105,7 +105,7 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) { testutil.AddPayload(obj, tc.payloadSize) addr := object.AddressOf(obj) - payload := slice.Copy(obj.Payload()) + payload := bytes.Clone(obj.Payload()) var putPrm PutPrm putPrm.SetObject(obj) diff --git a/pkg/local_object_storage/writecache/writecachebbolt/flush.go b/pkg/local_object_storage/writecache/writecachebbolt/flush.go index 9efee1dda..d0e89a385 100644 --- a/pkg/local_object_storage/writecache/writecachebbolt/flush.go +++ b/pkg/local_object_storage/writecache/writecachebbolt/flush.go @@ -17,7 +17,6 @@ import ( objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" "github.com/mr-tron/base58" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "go.etcd.io/bbolt" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -106,12 +105,12 @@ func (c *cache) flushSmallObjects(ctx context.Context) { if len(lastKey) == len(k) { copy(lastKey, k) } else { - lastKey = slice.Copy(k) + lastKey = bytes.Clone(k) } m = append(m, objectInfo{ addr: string(k), - data: slice.Copy(v), + data: bytes.Clone(v), }) } return nil diff --git a/pkg/local_object_storage/writecache/writecachebbolt/get.go b/pkg/local_object_storage/writecache/writecachebbolt/get.go index dede1fece..838b207be 100644 --- a/pkg/local_object_storage/writecache/writecachebbolt/get.go +++ b/pkg/local_object_storage/writecache/writecachebbolt/get.go @@ -1,6 +1,7 @@ package writecachebbolt import ( + "bytes" "context" "time" @@ -12,7 +13,6 @@ import ( apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "go.etcd.io/bbolt" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -95,7 +95,7 @@ func Get(db *bbolt.DB, key []byte) ([]byte, error) { if value == nil { return logicerr.Wrap(new(apistatus.ObjectNotFound)) } - value = slice.Copy(value) + value = bytes.Clone(value) return nil }) return value, metaerr.Wrap(err)