diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 514613c0d..44034ab86 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -216,21 +216,19 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc return r.deadEndProvider, nil } - addr := srv.Address() + var netAddr network.AddressGroup - var netAddr network.Address - - err := netAddr.FromString(addr) + err := netAddr.FromIterator(srv) if err != nil { return nil, fmt.Errorf("could not convert address to IP format: %w", err) } - if network.IsLocalAddress(r.loadAddrSrc, network.GroupFromAddress(netAddr)) { + if network.IsLocalAddress(r.loadAddrSrc, netAddr) { // if local => return no-op writer return loadcontroller.SimpleWriterProvider(new(nopLoadWriter)), nil } - c, err := r.clientCache.Get(network.GroupFromAddress(netAddr)) + c, err := r.clientCache.Get(netAddr) if err != nil { return nil, fmt.Errorf("could not initialize API client: %w", err) } @@ -369,16 +367,24 @@ func (c *cfg) PublicKey() []byte { return nodeKeyFromNetmap(c) } -func (c *cfg) Address() string { - return nodeAddressFromNetmap(c) +func (c *cfg) IterateAddresses(f func(string) bool) { + c.iterateNetworkAddresses(f) +} + +func (c *cfg) NumberOfAddresses() int { + return c.addressNum() } func (c *usedSpaceService) PublicKey() []byte { return nodeKeyFromNetmap(c.cfg) } -func (c *usedSpaceService) Address() string { - return nodeAddressFromNetmap(c.cfg) +func (c *usedSpaceService) IterateAddresses(f func(string) bool) { + c.cfg.iterateNetworkAddresses(f) +} + +func (c *usedSpaceService) NumberOfAddresses() int { + return c.cfg.addressNum() } func (c *usedSpaceService) AnnounceUsedSpace(ctx context.Context, req *containerV2.AnnounceUsedSpaceRequest) (*containerV2.AnnounceUsedSpaceResponse, error) { @@ -425,8 +431,11 @@ func (i *containerOnlyKeyRemoteServerInfo) PublicKey() []byte { return i.key } -func (*containerOnlyKeyRemoteServerInfo) Address() string { - return "" +func (*containerOnlyKeyRemoteServerInfo) IterateAddresses(func(string) bool) { +} + +func (*containerOnlyKeyRemoteServerInfo) NumberOfAddresses() int { + return 0 } func (l *loadPlacementBuilder) isNodeFromContainerKey(epoch uint64, cid *cid.ID, key []byte) (bool, error) { diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 730530447..fca68409a 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -68,8 +68,12 @@ func nodeKeyFromNetmap(c *cfg) []byte { return c.cfgNetmap.state.getNodeInfo().PublicKey() } -func nodeAddressFromNetmap(c *cfg) string { - return c.cfgNetmap.state.getNodeInfo().Address() +func (c *cfg) iterateNetworkAddresses(f func(string) bool) { + c.cfgNetmap.state.getNodeInfo().IterateAddresses(f) +} + +func (c *cfg) addressNum() int { + return c.cfgNetmap.state.getNodeInfo().NumberOfAddresses() } func initNetmapService(c *cfg) { diff --git a/cmd/neofs-node/reputation/common/remote.go b/cmd/neofs-node/reputation/common/remote.go index fec8f0768..d14098c04 100644 --- a/cmd/neofs-node/reputation/common/remote.go +++ b/cmd/neofs-node/reputation/common/remote.go @@ -70,21 +70,19 @@ func (rtp *remoteTrustProvider) InitRemote(srv reputationcommon.ServerInfo) (rep return rtp.deadEndProvider, nil } - addr := srv.Address() + var netAddr network.AddressGroup - var netAddr network.Address - - err := netAddr.FromString(addr) + err := netAddr.FromIterator(srv) if err != nil { return nil, fmt.Errorf("could not convert address to IP format: %w", err) } - if network.IsLocalAddress(rtp.localAddrSrc, network.GroupFromAddress(netAddr)) { + if network.IsLocalAddress(rtp.localAddrSrc, netAddr) { // if local => return no-op writer return trustcontroller.SimpleWriterProvider(new(NopReputationWriter)), nil } - c, err := rtp.clientCache.Get(network.GroupFromAddress(netAddr)) + c, err := rtp.clientCache.Get(netAddr) if err != nil { return nil, fmt.Errorf("could not initialize API client: %w", err) } diff --git a/cmd/neofs-node/reputation/common/util.go b/cmd/neofs-node/reputation/common/util.go index 56ee5de2b..a0a8a2946 100644 --- a/cmd/neofs-node/reputation/common/util.go +++ b/cmd/neofs-node/reputation/common/util.go @@ -37,8 +37,11 @@ func (i *OnlyKeyRemoteServerInfo) PublicKey() []byte { return i.Key } -func (*OnlyKeyRemoteServerInfo) Address() string { - return "" +func (*OnlyKeyRemoteServerInfo) IterateAddresses(func(string) bool) { +} + +func (*OnlyKeyRemoteServerInfo) NumberOfAddresses() int { + return 0 } const invalidPrmValFmt = "invalid parameter %s (%T):%v" diff --git a/pkg/services/container/announcement/load/route/deps.go b/pkg/services/container/announcement/load/route/deps.go index e6dba9240..c6389c48e 100644 --- a/pkg/services/container/announcement/load/route/deps.go +++ b/pkg/services/container/announcement/load/route/deps.go @@ -12,11 +12,13 @@ type ServerInfo interface { // from the route in a binary representation. PublicKey() []byte - // Returns network address of the node - // in the route. - // - // Can be empty. - Address() string + // Iterates over network addresses of the node + // in the route. Breaks iterating on true return + // of the handler. + IterateAddresses(func(string) bool) + + // Returns number of server's network addresses. + NumberOfAddresses() int } // Builder groups methods to route values in the network. diff --git a/pkg/services/reputation/common/deps.go b/pkg/services/reputation/common/deps.go index e2282bbfa..5ab59d47a 100644 --- a/pkg/services/reputation/common/deps.go +++ b/pkg/services/reputation/common/deps.go @@ -69,9 +69,11 @@ type ServerInfo interface { // from the route in a binary representation. PublicKey() []byte - // Returns network address of the node - // in the route. - // - // Can be empty. - Address() string + // Iterates over network addresses of the node + // in the route. Breaks iterating on true return + // of the handler. + IterateAddresses(func(string) bool) + + // Returns number of server's network addresses. + NumberOfAddresses() int }