frostfs-node/pkg/network/address.go
Leonard Lyubich 44def45ff4 [#31] network: Make the address a separate type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-10-02 11:25:35 +03:00

27 lines
471 B
Go

package network
import (
"github.com/multiformats/go-multiaddr"
)
// Address represents the NeoFS node
// network address.
type Address struct {
ma multiaddr.Multiaddr
}
func (a Address) String() string {
return a.ma.String()
}
// AddressFromString restores address from a string representation.
func AddressFromString(s string) (*Address, error) {
ma, err := multiaddr.NewMultiaddr(s)
if err != nil {
return nil, err
}
return &Address{
ma: ma,
}, nil
}