autopilot/manager: fix slice modifications

When appending to a slice, there is no guarantee the slice won't be
modified. So instead of appending to the global slice
availableHeuristics, we create a temporary local one.
This commit is contained in:
Johan T. Halseth committed 2019-10-31 10:17:31 +01:00
1 parent df5baa4275
commit f0ba4be758
1 file changed
+5 -1
+5 -1
View File
@@ -319,8 +319,12 @@ func (m *Manager) queryHeuristics(nodes map[NodeID]struct{}, localState bool) (
// We'll start by getting the scores from each available sub-heuristic,
// in addition the current agent heuristic.
var heuristics []AttachmentHeuristic
heuristics = append(heuristics, availableHeuristics...)
heuristics = append(heuristics, m.cfg.PilotCfg.Heuristic)
report := make(HeuristicScores)
for _, h := range append(availableHeuristics, m.cfg.PilotCfg.Heuristic) {
for _, h := range heuristics {
name := h.Name()
// If the agent heuristic is among the simple heuristics it