From 95ccbbc2f9e3e983bc56f04d345ccbe2e6c755c3 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 16 Jun 2021 13:49:00 +0300 Subject: [PATCH] [#607] network: Accept value instead of pointer in IsLocalAddress Signed-off-by: Leonard Lyubich --- pkg/network/address.go | 4 ++-- pkg/services/object/put/streamer.go | 4 ++-- pkg/services/object/util/placement.go | 4 ++-- pkg/services/policer/check.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/network/address.go b/pkg/network/address.go index d2905fd66c..df5669e186 100644 --- a/pkg/network/address.go +++ b/pkg/network/address.go @@ -128,8 +128,8 @@ func multiaddrStringFromHostAddr(host string) (string, error) { // IsLocalAddress returns true if network endpoint from local address // source is equal to network endpoint of passed address. -func IsLocalAddress(src LocalAddressSource, addr *Address) bool { - return src.LocalAddress().Equal(*addr) +func IsLocalAddress(src LocalAddressSource, addr Address) bool { + return src.LocalAddress().Equal(addr) } // HostAddrFromMultiaddr converts "/dns4/localhost/tcp/8080" to "localhost:8080". diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index c1461a73c3..afdbe9467d 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -150,7 +150,7 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget { var relay func(*network.Address) error if p.relay != nil { relay = func(addr *network.Address) error { - if network.IsLocalAddress(p.localAddrSrc, addr) { + if network.IsLocalAddress(p.localAddrSrc, *addr) { return errLocalAddress } @@ -167,7 +167,7 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget { traverseOpts: prm.traverseOpts, workerPool: p.workerPool, nodeTargetInitializer: func(addr *network.Address) transformer.ObjectTarget { - if network.IsLocalAddress(p.localAddrSrc, addr) { + if network.IsLocalAddress(p.localAddrSrc, *addr) { return &localTarget{ storage: p.localStore, } diff --git a/pkg/services/object/util/placement.go b/pkg/services/object/util/placement.go index d9ad62f138..787e7cf29d 100644 --- a/pkg/services/object/util/placement.go +++ b/pkg/services/object/util/placement.go @@ -56,7 +56,7 @@ func (p *localPlacement) BuildPlacement(addr *object.Address, policy *netmapSDK. continue } - if network.IsLocalAddress(p.localAddrSrc, addr) { + if network.IsLocalAddress(p.localAddrSrc, *addr) { return []netmapSDK.Nodes{{vs[i][j]}}, nil } } @@ -88,7 +88,7 @@ func (p *remotePlacement) BuildPlacement(addr *object.Address, policy *netmapSDK continue } - if network.IsLocalAddress(p.localAddrSrc, addr) { + if network.IsLocalAddress(p.localAddrSrc, *addr) { vs[i] = append(vs[i][:j], vs[i][j+1:]...) j-- } diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index 4f03e0fd4b..6ba2f9cf21 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -68,7 +68,7 @@ func (p *Policer) processNodes(ctx context.Context, addr *object.Address, nodes continue } - if network.IsLocalAddress(p.localAddrSrc, node) { + if network.IsLocalAddress(p.localAddrSrc, *node) { if shortage == 0 { // we can call the redundant copy callback // here to slightly improve the performance