autopilot: take channel min htlc from config

This commit is contained in:
Joost Jager 2019-11-25 13:36:40 +01:00
parent b6eb3a69ba
commit 61e114f201
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
2 changed files with 18 additions and 17 deletions

2
lnd.go
View File

@ -479,7 +479,7 @@ func Main(lisCfg ListenerCfg) error {
// Set up an autopilot manager from the current config. This will be
// used to manage the underlying autopilot agent, starting and stopping
// it at will.
atplCfg, err := initAutoPilot(server, cfg.Autopilot)
atplCfg, err := initAutoPilot(server, cfg.Autopilot, mainChain)
if err != nil {
err := fmt.Errorf("Unable to initialize autopilot: %v", err)
ltndLog.Error(err)

View File

@ -70,10 +70,11 @@ func validateAtplCfg(cfg *autoPilotConfig) ([]*autopilot.WeightedHeuristic,
// chanController is an implementation of the autopilot.ChannelController
// interface that's backed by a running lnd instance.
type chanController struct {
server *server
private bool
minConfs int32
confTarget uint32
server *server
private bool
minConfs int32
confTarget uint32
chanMinHtlcIn lnwire.MilliSatoshi
}
// OpenChannel opens a channel to a target peer, with a capacity of the
@ -91,9 +92,6 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
return err
}
// TODO(halseth): make configurable?
minHtlcIn := lnwire.NewMSatFromSatoshis(1)
// Construct the open channel request and send it to the server to begin
// the funding workflow.
req := &openChanReq{
@ -102,7 +100,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
subtractFees: true,
localFundingAmt: amt,
pushAmt: 0,
minHtlcIn: minHtlcIn,
minHtlcIn: c.chanMinHtlcIn,
fundingFeePerKw: feePerKw,
private: c.private,
remoteCsvDelay: 0,
@ -136,11 +134,13 @@ func (c *chanController) SpliceOut(chanPoint *wire.OutPoint,
// autopilot.ChannelController interface.
var _ autopilot.ChannelController = (*chanController)(nil)
// initAutoPilot initializes a new autopilot.ManagerCfg to manage an
// autopilot.Agent instance based on the passed configuration struct. The agent
// and all interfaces needed to drive it won't be launched before the Manager's
// initAutoPilot initializes a new autopilot.ManagerCfg to manage an autopilot.
// Agent instance based on the passed configuration structs. The agent and all
// interfaces needed to drive it won't be launched before the Manager's
// StartAgent method is called.
func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.ManagerCfg, error) {
func initAutoPilot(svr *server, cfg *autoPilotConfig, chainCfg *chainConfig) (
*autopilot.ManagerCfg, error) {
atplLog.Infof("Instantiating autopilot with max_channels=%d, allocation=%f, "+
"min_chan_size=%d, max_chan_size=%d, private=%t, min_confs=%d, "+
"conf_target=%d", cfg.MaxChannels, cfg.Allocation, cfg.MinChannelSize,
@ -173,10 +173,11 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.ManagerCfg, er
Self: self,
Heuristic: weightedAttachment,
ChanController: &chanController{
server: svr,
private: cfg.Private,
minConfs: cfg.MinConfs,
confTarget: cfg.ConfTarget,
server: svr,
private: cfg.Private,
minConfs: cfg.MinConfs,
confTarget: cfg.ConfTarget,
chanMinHtlcIn: chainCfg.MinHTLCIn,
},
WalletBalance: func() (btcutil.Amount, error) {
return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs)