forked from TrueCloudLab/frostfs-node
[#1817] network: Allow to use network addresses from the iterator
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
76893bdc50
commit
236414df49
21 changed files with 203 additions and 17 deletions
|
@ -17,6 +17,11 @@ func (x Node) PublicKey() []byte {
|
|||
// IterateAddresses iterates over all announced network addresses
|
||||
// and passes them into f. Handler MUST NOT be nil.
|
||||
func (x Node) IterateAddresses(f func(string) bool) {
|
||||
for _, addr := range (netmap.NodeInfo)(x).ExternalAddresses() {
|
||||
if f(addr) {
|
||||
return
|
||||
}
|
||||
}
|
||||
(netmap.NodeInfo)(x).IterateNetworkEndpoints(f)
|
||||
}
|
||||
|
||||
|
@ -25,6 +30,11 @@ func (x Node) NumberOfAddresses() int {
|
|||
return (netmap.NodeInfo)(x).NumberOfNetworkEndpoints()
|
||||
}
|
||||
|
||||
// ExternalAddresses returns external addresses of a node.
|
||||
func (x Node) ExternalAddresses() []string {
|
||||
return (netmap.NodeInfo)(x).ExternalAddresses()
|
||||
}
|
||||
|
||||
// Nodes is a named type of []netmap.NodeInfo which provides interface needed
|
||||
// in the current repository. Nodes is expected to be used everywhere instead
|
||||
// of direct usage of []netmap.NodeInfo, so it represents a type mediator.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue