autopilot/interface+agent: return NodeScore from NodeScores

Since NodeScores no longer returns fully populated AttachmentDirectives,
we make this explicit by defining a new type NodeScore that includes a
subset of what the AttachmentDirective does.
This commit is contained in:
Johan T. Halseth committed 2019-01-08 10:23:50 +01:00
1 parent 25de66d27b
commit 5b1e72a019
5 files changed
+129 -173

No files matched your search

+2 -11
View File
@@ -573,25 +573,16 @@ func (a *Agent) openChans(availableFunds btcutil.Amount, numChans uint32,
log.Debugf("Got scores for %d nodes", len(scores))
// Temporary convert to NodeScore.
nodeScores := make(map[NodeID]*NodeScore)
for k, v := range scores {
nodeScores[k] = &NodeScore{
NodeID: v.NodeID,
Score: v.Score,
}
}
// Now use the score to make a weighted choice which nodes to attempt
// to open channels to.
nodeScores, err = chooseN(numChans, nodeScores)
scores, err = chooseN(numChans, scores)
if err != nil {
return fmt.Errorf("Unable to make weighted choice: %v",
err)
}
chanCandidates := make(map[NodeID]*AttachmentDirective)
for nID := range nodeScores {
for nID := range scores {
// Add addresses to the candidates.
addrs := addresses[nID]