[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-09-28 08:44:40 +03:00 committed by Alex Vanin
parent 81e0396c13
commit 312e356a75

View file

@ -1,6 +1,7 @@
package main package main
import ( import (
"bytes"
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"crypto/sha256" "crypto/sha256"
@ -24,7 +25,6 @@ import (
cntrwrp "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" cntrwrp "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
nmwrp "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/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/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/network"
objectTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc" objectTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc"
objectService "github.com/nspcc-dev/neofs-node/pkg/services/object" objectService "github.com/nspcc-dev/neofs-node/pkg/services/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl" "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) nm, err := netmap.GetLatestNetworkMap(c.nmSrc)
if err == nil { if err == nil {
addr := info.AddressGroup() key := info.PublicKey()
for i := range nm.Nodes { 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]) return &reputationClient{
if err == nil { Client: cl.(coreclient.Client),
if netAddr.Intersects(addr) { prm: prm,
prm := truststorage.UpdatePrm{} cons: c,
prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey())) }, nil
return &reputationClient{
Client: cl.(coreclient.Client),
prm: prm,
cons: c,
}, nil
}
} }
} }
} else { } else {