Skip to content

Commit

Permalink
node/control/evacuate: use slices.DeleteFunc for clean up
Browse files Browse the repository at this point in the history
It uses fewer code lines.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Sep 4, 2024
1 parent 913fc84 commit 3a9e0d0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/services/control/server/evacuate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"slices"

"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
Expand Down Expand Up @@ -78,12 +79,9 @@ func (s *Server) replicate(addr oid.Address, obj *objectSDK.Object) error {

nodes := placement.FlattenNodes(ns)
bs := (*keys.PublicKey)(&s.key.PublicKey).Bytes()
for i := range nodes {
if bytes.Equal(nodes[i].PublicKey(), bs) {
copy(nodes[i:], nodes[i+1:])
nodes = nodes[:len(nodes)-1]
}
}
nodes = slices.DeleteFunc(nodes, func(info netmap.NodeInfo) bool {
return bytes.Equal(info.PublicKey(), bs)
})

var res replicatorResult
var task replicator.Task
Expand Down

0 comments on commit 3a9e0d0

Please sign in to comment.