[#607] network: Make AddressGroup.WriteToNodeInfo method a function

Method implementation doesn't use any private logic.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-23 12:50:40 +03:00 committed by Leonard Lyubich
parent 359bbe319a
commit 119031c8c7
2 changed files with 9 additions and 6 deletions

View file

@ -107,12 +107,14 @@ func (x *AddressGroup) FromIterator(iter MultiAddressIterator) (err error) {
}
// WriteToNodeInfo writes AddressGroup to netmap.NodeInfo structure.
func (x AddressGroup) WriteToNodeInfo(ni *netmap.NodeInfo) {
addrs := make([]string, len(x))
func WriteToNodeInfo(g AddressGroup, ni *netmap.NodeInfo) {
num := g.Len()
addrs := make([]string, 0, num)
for i := range x {
addrs[i] = x[i].String()
}
g.IterateAddresses(func(addr Address) bool {
addrs = append(addrs, addr.String())
return false
})
ni.SetAddresses(addrs...)
}