mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 17:05:50 +02:00
autopilot: trigger agent channel open on new scores
This commit adds a new signal to the autopilot agent, meant to signal when any of the available heuristics has gotten an update. We currently use this to trigger a new channel opening after the external scores have been updated.
This commit is contained in:
@@ -358,6 +358,9 @@ func (m *Manager) queryHeuristics(nodes map[NodeID]struct{}, localState bool) (
|
||||
// SetNodeScores is used to set the scores of the given heuristic, if it is
|
||||
// active, and ScoreSettable.
|
||||
func (m *Manager) SetNodeScores(name string, scores map[NodeID]float64) error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
// It must be ScoreSettable to be available for external
|
||||
// scores.
|
||||
s, ok := m.cfg.PilotCfg.Heuristic.(ScoreSettable)
|
||||
@@ -376,5 +379,11 @@ func (m *Manager) SetNodeScores(name string, scores map[NodeID]float64) error {
|
||||
return fmt.Errorf("heuristic with name %v not found", name)
|
||||
}
|
||||
|
||||
// If the autopilot agent is active, notify about the updated
|
||||
// heuristic.
|
||||
if m.pilot != nil {
|
||||
m.pilot.OnHeuristicUpdate(m.cfg.PilotCfg.Heuristic)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user