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 2019-09-18 13:25:12 +02:00
parent df5baa4275
commit f0ba4be758
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -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