autopilot: modify interfaces to specify *exactly* how many chans to open

In this commit, we fix a regression introduced by a recent change which
would allow the agent to detect a channel as failed, and blacklist the
node, promising faster convergence with the ideal state of the
heuristic.

The source of this bug is that we would use the set of blacklisted
nodes in order to compute how many additional channels we should open.
If 10 failures happened, then we would think that we had opened up 10
channels, and stop much earlier than we actually should.

To fix this, while ensuring we don’t retry to failed peers, the
NeedMoreChans method will now return *how* anymore channels to open,
and the Select method will take in how many channels it should try to
open *exactly*.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-02-08 20:08:18 -08:00
1 parent d1c12202ca
commit 9f52372cd2
5 files changed
+67 -49

No files matched your search

+3 -2
View File
@@ -362,7 +362,7 @@ func (a *Agent) controller(startingBalance btcutil.Amount) {
// consult our channel attachment heuristic to
// determine if we should open up any additional
// channels or modify existing channels.
availableFunds, needMore := a.cfg.Heuristic.NeedMoreChans(
availableFunds, numChans, needMore := a.cfg.Heuristic.NeedMoreChans(
totalChans, a.totalBalance,
)
if !needMore {
@@ -387,7 +387,7 @@ func (a *Agent) controller(startingBalance btcutil.Amount) {
// for us to use.
chanCandidates, err := a.cfg.Heuristic.Select(
a.cfg.Self, a.cfg.Graph, availableFunds,
nodesToSkip,
numChans, nodesToSkip,
)
if err != nil {
log.Errorf("Unable to select candidates for "+
@@ -419,6 +419,7 @@ func (a *Agent) controller(startingBalance btcutil.Amount) {
go func(directive AttachmentDirective) {
pub := directive.PeerKey
err := a.cfg.ChanController.OpenChannel(
directive.PeerKey,
directive.ChanAmt,
directive.Addrs,