[#607] ir: Work with AddressGroup instead of single Address

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-22 18:34:44 +03:00 committed by Leonard Lyubich
parent 9033cf5aa1
commit f7b42a1525
3 changed files with 13 additions and 14 deletions

View file

@ -118,9 +118,9 @@ func (ap *Processor) findStorageGroups(cid *cid.ID, shuffled netmap.Nodes) []*ob
zap.Int("total_tries", ln),
)
var netAddr network.Address
var netAddr network.AddressGroup
err := netAddr.FromString(shuffled[i].Address())
err := netAddr.FromIterator(shuffled[i])
if err != nil {
log.Warn("can't parse remote address", zap.String("error", err.Error()))

View file

@ -26,7 +26,7 @@ type (
// NeoFSClientCache is an interface for cache of neofs RPC clients
NeoFSClientCache interface {
Get(address network.Address) (SDKClient.Client, error)
Get(network.AddressGroup) (SDKClient.Client, error)
}
TaskManager interface {

View file

@ -49,10 +49,10 @@ func newClientCache(p *clientCacheParams) *ClientCache {
}
}
func (c *ClientCache) Get(address network.Address) (client.Client, error) {
func (c *ClientCache) Get(address network.AddressGroup) (client.Client, error) {
// Because cache is used by `ClientCache` exclusively,
// client will always have valid key.
return c.cache.Get(network.GroupFromAddress(address))
return c.cache.Get(address)
}
// GetSG polls the container from audit task to get the object by id.
@ -75,9 +75,9 @@ func (c *ClientCache) getSG(ctx context.Context, addr *object.Address, nm *netma
getParams.WithAddress(addr)
for _, node := range placement.FlattenNodes(nodes) {
var netAddr network.Address
var netAddr network.AddressGroup
err := netAddr.FromString(node.Address())
err := netAddr.FromIterator(node)
if err != nil {
c.log.Warn("can't parse remote address",
zap.String("address", node.Address()),
@ -89,7 +89,6 @@ func (c *ClientCache) getSG(ctx context.Context, addr *object.Address, nm *netma
cli, err := c.Get(netAddr)
if err != nil {
c.log.Warn("can't setup remote connection",
zap.Stringer("address", netAddr),
zap.String("error", err.Error()))
continue
@ -139,11 +138,11 @@ func (c *ClientCache) GetHeader(task *audit.Task, node *netmap.Node, id *object.
headParams.WithMainFields()
headParams.WithAddress(objAddress)
var netAddr network.Address
var netAddr network.AddressGroup
err := netAddr.FromString(node.Address())
err := netAddr.FromIterator(node)
if err != nil {
return nil, fmt.Errorf("can't parse remote address %s: %w", node.Address(), err)
return nil, fmt.Errorf("can't parse remote address: %w", err)
}
cli, err := c.Get(netAddr)
@ -177,11 +176,11 @@ func (c *ClientCache) GetRangeHash(task *audit.Task, node *netmap.Node, id *obje
rangeParams.WithRangeList(rng)
rangeParams.WithSalt(nil) // it MUST be nil for correct hash concatenation in PDP game
var netAddr network.Address
var netAddr network.AddressGroup
err := netAddr.FromString(node.Address())
err := netAddr.FromIterator(node)
if err != nil {
return nil, fmt.Errorf("can't parse remote address %s: %w", node.Address(), err)
return nil, fmt.Errorf("can't parse remote address: %w", err)
}
cli, err := c.Get(netAddr)