From 47fe8911a3c19760fe0c24898124b1826dd8c480 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 16 Jun 2021 14:12:03 +0300 Subject: [PATCH] [#607] network: Rename Address.HostAddrString method to HostAddr Return tyype is clear from the method's signature and docs, there is no point in reflecting it in the name. Signed-off-by: Leonard Lyubich --- cmd/neofs-cli/modules/root.go | 2 +- pkg/network/address.go | 4 ++-- pkg/network/address_test.go | 4 ++-- pkg/network/cache/client.go | 2 +- pkg/services/object/get/get_test.go | 4 ++-- pkg/services/object/search/search_test.go | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index dca7186411..e52ba4e7b8 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -258,7 +258,7 @@ func getSDKClient(key *ecdsa.PrivateKey) (client.Client, error) { } options := []client.Option{ - client.WithAddress(netAddr.HostAddrString()), + client.WithAddress(netAddr.HostAddr()), client.WithDefaultPrivateKey(key), } diff --git a/pkg/network/address.go b/pkg/network/address.go index 1bba70f693..5535975eee 100644 --- a/pkg/network/address.go +++ b/pkg/network/address.go @@ -63,10 +63,10 @@ func (a Address) IPAddrString() (string, error) { return ip.String(), nil } -// HostAddrString returns host address in string format. +// HostAddr returns host address in string format. // // Panics if host address cannot be fetched from Address. -func (a Address) HostAddrString() string { +func (a Address) HostAddr() string { _, host, err := manet.DialArgs(a.ma) if err != nil { // the only correct way to construct Address is AddressFromString diff --git a/pkg/network/address_test.go b/pkg/network/address_test.go index 6ffeaacb9a..c218b0cd4a 100644 --- a/pkg/network/address_test.go +++ b/pkg/network/address_test.go @@ -62,7 +62,7 @@ func TestAddress_HostAddrString(t *testing.T) { for _, testcase := range testcases { addr := Address{testcase.ma} - got := addr.HostAddrString() + got := addr.HostAddr() require.Equal(t, testcase.exp, got) } @@ -75,7 +75,7 @@ func TestAddress_HostAddrString(t *testing.T) { for _, testcase := range testcases { addr := Address{testcase} - require.Panics(t, func() { addr.HostAddrString() }) + require.Panics(t, func() { addr.HostAddr() }) } }) } diff --git a/pkg/network/cache/client.go b/pkg/network/cache/client.go index e62f37334c..bc8152894b 100644 --- a/pkg/network/cache/client.go +++ b/pkg/network/cache/client.go @@ -54,7 +54,7 @@ func (c *ClientCache) Get(netAddr *network.Address) (client.Client, error) { return cli, nil } - opts := append(c.opts, client.WithAddress(netAddr.HostAddrString())) + opts := append(c.opts, client.WithAddress(netAddr.HostAddr())) if netAddr.TLSEnabled() { opts = append(opts, client.WithTLSConfig(&tls.Config{})) diff --git a/pkg/services/object/get/get_test.go b/pkg/services/object/get/get_test.go index 70841a05af..5a0c3d902c 100644 --- a/pkg/services/object/get/get_test.go +++ b/pkg/services/object/get/get_test.go @@ -83,7 +83,7 @@ func (p *testPlacementBuilder) BuildPlacement(addr *objectSDK.Address, _ *netmap } func (c *testClientCache) get(mAddr *network.Address) (getClient, error) { - v, ok := c.clients[mAddr.HostAddrString()] + v, ok := c.clients[mAddr.HostAddr()] if !ok { return nil, errors.New("could not construct client") } @@ -410,7 +410,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) { na, err := network.AddressFromString(a) require.NoError(t, err) - as[j] = na.HostAddrString() + as[j] = na.HostAddr() ni := netmap.NewNodeInfo() ni.SetAddress(a) diff --git a/pkg/services/object/search/search_test.go b/pkg/services/object/search/search_test.go index ab7c8250a1..1b2aa94ded 100644 --- a/pkg/services/object/search/search_test.go +++ b/pkg/services/object/search/search_test.go @@ -85,7 +85,7 @@ func (p *testPlacementBuilder) BuildPlacement(addr *objectSDK.Address, _ *netmap } func (c *testClientCache) get(mAddr *network.Address) (searchClient, error) { - v, ok := c.clients[mAddr.HostAddrString()] + v, ok := c.clients[mAddr.HostAddr()] if !ok { return nil, errors.New("could not construct client") } @@ -204,7 +204,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) { na, err := network.AddressFromString(a) require.NoError(t, err) - as[j] = na.HostAddrString() + as[j] = na.HostAddr() ni := netmap.NewNodeInfo() ni.SetAddress(a)