routing: add mission control import functionality

This commit is contained in:
carla
2021-03-18 10:46:45 +02:00
parent 6046c5cf86
commit 22491ad567
2 changed files with 71 additions and 0 deletions

View File

@@ -342,6 +342,27 @@ func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
return m.state.getSnapshot()
}
// ImportHistory imports the set of mission control results provided to our
// in-memory state. These results are not persisted, so will not survive
// restarts.
func (m *MissionControl) ImportHistory(history *MissionControlSnapshot) error {
if history == nil {
return errors.New("cannot import nil history")
}
m.Lock()
defer m.Unlock()
log.Infof("Importing history snapshot with %v pairs to mission control",
len(history.Pairs))
imported := m.state.importSnapshot(history)
log.Infof("Imported %v results to mission control", imported)
return nil
}
// GetPairHistorySnapshot returns the stored history for a given node pair.
func (m *MissionControl) GetPairHistorySnapshot(
fromNode, toNode route.Vertex) TimedPairResult {