Files
mesh-contracts/placement/go/clients/meshmoduleassignerclient/reads.go
T

20 lines
623 B
Go

package meshmoduleassignerclient
import "sort"
// MachineNames is every machine the seat places modules on, sorted, from its state `placement` as a reader holds its
// keys: each with a node key `<node>.node` or, in the form before, `placement.<node>`. Module keys and keys of the
// state's other kinds are passed over.
func MachineNames(keys map[string][]byte) []string {
seen := map[string]bool{}
out := []string{}
for k := range keys {
if node, _, kind, err := ParseKey(k); err == nil && kind != ModuleKind && !seen[node] {
seen[node] = true
out = append(out, node)
}
}
sort.Strings(out)
return out
}