mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-03 00:10:20 +02:00
autopilot/manager: add QueryHeuristics
Proxies a query request to the active agent.
This commit is contained in:
parent
6c556fd92a
commit
8f54a2bd6f
@ -1,6 +1,7 @@
|
|||||||
package autopilot
|
package autopilot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@ -267,3 +268,22 @@ func (m *Manager) StopAgent() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryHeuristics queries the active autopilot agent for node scores.
|
||||||
|
func (m *Manager) QueryHeuristics(nodes []NodeID) (HeuristicScores, error) {
|
||||||
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
|
|
||||||
|
// Not active, so we can return early.
|
||||||
|
if m.pilot == nil {
|
||||||
|
return nil, fmt.Errorf("autopilot not active")
|
||||||
|
}
|
||||||
|
|
||||||
|
n := make(map[NodeID]struct{})
|
||||||
|
for _, node := range nodes {
|
||||||
|
n[node] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Querying heuristics for %d nodes", len(n))
|
||||||
|
return m.pilot.queryHeuristics(n)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user