Allow setting a friendly name for the local node (fixes #65)

This commit is contained in:
Jakob Borg
2014-02-10 20:54:37 +01:00
parent b6814241cc
commit 3a5b816125
5 changed files with 137 additions and 65 deletions

View File

@@ -178,3 +178,25 @@ func clusterHash(nodes []NodeConfiguration) string {
}
return fmt.Sprintf("%x", h.Sum(nil))
}
func cleanNodeList(nodes []NodeConfiguration, myID string) []NodeConfiguration {
var myIDExists bool
for _, node := range nodes {
if node.NodeID == myID {
myIDExists = true
break
}
}
if !myIDExists {
nodes = append(nodes, NodeConfiguration{
NodeID: myID,
Addresses: []string{"dynamic"},
Name: "",
})
}
sort.Sort(NodeConfigurationList(nodes))
return nodes
}