forked from TrueCloudLab/frostfs-node
[#607] network: Do not work with Address pointers
`network.Address` structure in most cases created once and used read-only. Replace `AddressFromString` function with `Address.FromString` method with the same purpose and implementation. Make all libraries to work with value. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
5de074f24c
commit
adbbad0beb
35 changed files with 128 additions and 97 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type clientCache interface {
|
||||
Get(*network.Address) (apiClient.Client, error)
|
||||
Get(network.Address) (apiClient.Client, error)
|
||||
}
|
||||
|
||||
// clientKeyRemoteProvider must provide remote writer and take into account
|
||||
|
@ -72,12 +72,14 @@ func (rtp *remoteTrustProvider) InitRemote(srv reputationcommon.ServerInfo) (rep
|
|||
|
||||
addr := srv.Address()
|
||||
|
||||
netAddr, err := network.AddressFromString(addr)
|
||||
var netAddr network.Address
|
||||
|
||||
err := netAddr.FromString(addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not convert address to IP format: %w", err)
|
||||
}
|
||||
|
||||
if network.IsLocalAddress(rtp.localAddrSrc, *netAddr) {
|
||||
if network.IsLocalAddress(rtp.localAddrSrc, netAddr) {
|
||||
// if local => return no-op writer
|
||||
return trustcontroller.SimpleWriterProvider(new(NopReputationWriter)), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue