Revert "Move the metadata parsing code to node.go"

This reverts commit ac6289b5bf95e8903ea90ddf807832a2358371b0.
This commit is contained in:
kaiyou 2020-05-07 09:58:31 +02:00 committed by Leo Antunes
parent beae4f2044
commit 9fdab65237
2 changed files with 12 additions and 17 deletions

13
main.go
View File

@ -66,7 +66,18 @@ func main() {
for {
select {
case rawNodes := <-nodec:
nodes := parseNodesMeta(rawNodes)
logrus.Info("cluster members:\n")
nodes := make([]node, 0, len(rawNodes))
for _, node := range rawNodes {
meta, err := decodeNodeMeta(node.Meta)
if err != nil {
logrus.Warnf("\t addr: %s, could not decode metadata", node.Addr)
continue
}
node.nodeMeta = meta
nodes = append(nodes, node)
logrus.Infof("\taddr: %s, overlay: %s, pubkey: %s", node.Addr, node.OverlayAddr, node.PubKey)
}
if err := wg.setUpInterface(nodes); err != nil {
logrus.WithError(err).Error("could not up interface")
wg.downInterface()

16
node.go
View File

@ -49,19 +49,3 @@ func decodeNodeMeta(b []byte) (nodeMeta, error) {
}
return nm, nil
}
func parseNodesMeta(rawNodes []node) []node {
logrus.Info("cluster members:\n")
nodes := make([]node, 0, len(rawNodes))
for _, node := range rawNodes {
meta, err := decodeNodeMeta(node.Meta)
if err != nil {
logrus.Warnf("\t addr: %s, could not decode metadata", node.Addr)
continue
}
node.nodeMeta = meta
nodes = append(nodes, node)
logrus.Infof("\taddr: %s, overlay: %s, pubkey: %s", node.Addr, node.OverlayAddr, node.PubKey)
}
return nodes
}