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

+9 -6
View File
@@ -111,17 +111,20 @@ type AttachmentHeuristic interface {
// opened within the channel graph. If the heuristic decides that we do
// indeed need more channels, then the second argument returned will
// represent the amount of additional funds to be used towards creating
// channels.
//
// TODO(roasbeef): return number of chans? ensure doesn't go over
NeedMoreChans(chans []Channel, balance btcutil.Amount) (btcutil.Amount, bool)
// channels. This method should also return the exact *number* of
// additional channels that are needed in order to converge towards our
// ideal state.
NeedMoreChans(chans []Channel, balance btcutil.Amount) (btcutil.Amount, uint32, bool)
// Select is a method that given the current state of the channel
// graph, a set of nodes to ignore, and an amount of available funds,
// should return a set of attachment directives which describe which
// additional channels should be opened within the graph to push the
// heuristic back towards its equilibrium state.
Select(self *btcec.PublicKey, graph ChannelGraph, amtToUse btcutil.Amount,
// heuristic back towards its equilibrium state. The numNewChans
// argument represents the additional number of channels that should be
// open.
Select(self *btcec.PublicKey, graph ChannelGraph,
amtToUse btcutil.Amount, numNewChans uint32,
skipNodes map[NodeID]struct{}) ([]AttachmentDirective, error)
}