2022-06-08 23:18:26 +00:00
|
|
|
package netmap
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
import "github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
2022-06-08 23:18:26 +00:00
|
|
|
|
|
|
|
// Node is a named type of netmap.NodeInfo which provides interface needed
|
|
|
|
// in the current repository. Node is expected to be used everywhere instead
|
|
|
|
// of direct usage of netmap.NodeInfo, so it represents a type mediator.
|
|
|
|
type Node netmap.NodeInfo
|
|
|
|
|
|
|
|
// PublicKey returns public key bound to the storage node.
|
|
|
|
//
|
|
|
|
// Return value MUST NOT be mutated, make a copy first.
|
|
|
|
func (x Node) PublicKey() []byte {
|
|
|
|
return (netmap.NodeInfo)(x).PublicKey()
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-12-14 10:15:17 +00:00
|
|
|
(netmap.NodeInfo)(x).IterateNetworkEndpoints(f)
|
2022-09-26 12:34:01 +00:00
|
|
|
for _, addr := range (netmap.NodeInfo)(x).ExternalAddresses() {
|
|
|
|
if f(addr) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 23:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NumberOfAddresses returns number of announced network addresses.
|
|
|
|
func (x Node) NumberOfAddresses() int {
|
|
|
|
return (netmap.NodeInfo)(x).NumberOfNetworkEndpoints()
|
|
|
|
}
|
|
|
|
|
2022-09-26 12:34:01 +00:00
|
|
|
// ExternalAddresses returns external addresses of a node.
|
|
|
|
func (x Node) ExternalAddresses() []string {
|
|
|
|
return (netmap.NodeInfo)(x).ExternalAddresses()
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:18:26 +00:00
|
|
|
// 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.
|
|
|
|
type Nodes []netmap.NodeInfo
|