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:
5 files changed
+129
-173
No files matched your search
+2
-11
@@ -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]
|
||||
|
||||
|
||||
Reference in new issue
Block a user