From 312e356a75792f08651c19673682f021b446f5fc Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 28 Sep 2021 08:44:40 +0300 Subject: [PATCH] [#645] object: Compare public keys in reputation client constructor In previous implementation of reputation client constructor compared network addresses to check the membership of the network map. Replace network addresses comparison with public key comparison. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/object.go | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 9ddd66a96..b3f88b64e 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "context" "crypto/ecdsa" "crypto/sha256" @@ -24,7 +25,6 @@ import ( cntrwrp "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" nmwrp "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper" "github.com/nspcc-dev/neofs-node/pkg/morph/event" - "github.com/nspcc-dev/neofs-node/pkg/network" objectTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc" objectService "github.com/nspcc-dev/neofs-node/pkg/services/object" "github.com/nspcc-dev/neofs-node/pkg/services/object/acl" @@ -534,23 +534,18 @@ func (c *reputationClientConstructor) Get(info coreclient.NodeInfo) (client.Clie nm, err := netmap.GetLatestNetworkMap(c.nmSrc) if err == nil { - addr := info.AddressGroup() + key := info.PublicKey() for i := range nm.Nodes { - var netAddr network.AddressGroup + if bytes.Equal(nm.Nodes[i].PublicKey(), key) { + prm := truststorage.UpdatePrm{} + prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey())) - err := netAddr.FromIterator(nm.Nodes[i]) - if err == nil { - if netAddr.Intersects(addr) { - prm := truststorage.UpdatePrm{} - prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey())) - - return &reputationClient{ - Client: cl.(coreclient.Client), - prm: prm, - cons: c, - }, nil - } + return &reputationClient{ + Client: cl.(coreclient.Client), + prm: prm, + cons: c, + }, nil } } } else {