Generate the local node directly in main.go
Instead of using a trivial function, simply generate the local node from main.go, manually assign fields from the nodeMeta struct.
This commit is contained in:
parent
0162f9da2c
commit
3a882eb112
|
@ -26,15 +26,7 @@ func (n *Node) String() string {
|
|||
return n.Addr.String()
|
||||
}
|
||||
|
||||
func MakeLocalNode(overlayAddr net.IPNet, pubKey string) Node {
|
||||
return Node{
|
||||
nodeMeta: nodeMeta{
|
||||
OverlayAddr: overlayAddr,
|
||||
PubKey: pubKey,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the node metadata to bytes, in a deterministic reversible way
|
||||
func (n *Node) Encode(limit int) ([]byte, error) {
|
||||
buf := &bytes.Buffer{}
|
||||
if err := gob.NewEncoder(buf).Encode(n.nodeMeta); err != nil {
|
||||
|
|
4
main.go
4
main.go
|
@ -44,7 +44,9 @@ func main() {
|
|||
}
|
||||
|
||||
wg.AssignOverlayAddr((*net.IPNet)(config.OverlayNet), cluster.LocalName)
|
||||
localNode := common.MakeLocalNode(wg.OverlayAddr, wg.PubKey.String())
|
||||
localNode := common.Node{}
|
||||
localNode.OverlayAddr = wg.OverlayAddr
|
||||
localNode.PubKey = wg.PubKey.String()
|
||||
cluster.Update(localNode)
|
||||
|
||||
nodec := cluster.Members() // avoid deadlocks by starting before join
|
||||
|
|
Loading…
Reference in New Issue