autopilot: take channel min htlc from config
This commit is contained in:
parent
b6eb3a69ba
commit
61e114f201
2
lnd.go
2
lnd.go
@ -479,7 +479,7 @@ func Main(lisCfg ListenerCfg) error {
|
|||||||
// Set up an autopilot manager from the current config. This will be
|
// Set up an autopilot manager from the current config. This will be
|
||||||
// used to manage the underlying autopilot agent, starting and stopping
|
// used to manage the underlying autopilot agent, starting and stopping
|
||||||
// it at will.
|
// it at will.
|
||||||
atplCfg, err := initAutoPilot(server, cfg.Autopilot)
|
atplCfg, err := initAutoPilot(server, cfg.Autopilot, mainChain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Unable to initialize autopilot: %v", err)
|
err := fmt.Errorf("Unable to initialize autopilot: %v", err)
|
||||||
ltndLog.Error(err)
|
ltndLog.Error(err)
|
||||||
|
33
pilot.go
33
pilot.go
@ -70,10 +70,11 @@ func validateAtplCfg(cfg *autoPilotConfig) ([]*autopilot.WeightedHeuristic,
|
|||||||
// chanController is an implementation of the autopilot.ChannelController
|
// chanController is an implementation of the autopilot.ChannelController
|
||||||
// interface that's backed by a running lnd instance.
|
// interface that's backed by a running lnd instance.
|
||||||
type chanController struct {
|
type chanController struct {
|
||||||
server *server
|
server *server
|
||||||
private bool
|
private bool
|
||||||
minConfs int32
|
minConfs int32
|
||||||
confTarget uint32
|
confTarget uint32
|
||||||
|
chanMinHtlcIn lnwire.MilliSatoshi
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenChannel opens a channel to a target peer, with a capacity of the
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(halseth): make configurable?
|
|
||||||
minHtlcIn := lnwire.NewMSatFromSatoshis(1)
|
|
||||||
|
|
||||||
// Construct the open channel request and send it to the server to begin
|
// Construct the open channel request and send it to the server to begin
|
||||||
// the funding workflow.
|
// the funding workflow.
|
||||||
req := &openChanReq{
|
req := &openChanReq{
|
||||||
@ -102,7 +100,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
|
|||||||
subtractFees: true,
|
subtractFees: true,
|
||||||
localFundingAmt: amt,
|
localFundingAmt: amt,
|
||||||
pushAmt: 0,
|
pushAmt: 0,
|
||||||
minHtlcIn: minHtlcIn,
|
minHtlcIn: c.chanMinHtlcIn,
|
||||||
fundingFeePerKw: feePerKw,
|
fundingFeePerKw: feePerKw,
|
||||||
private: c.private,
|
private: c.private,
|
||||||
remoteCsvDelay: 0,
|
remoteCsvDelay: 0,
|
||||||
@ -136,11 +134,13 @@ func (c *chanController) SpliceOut(chanPoint *wire.OutPoint,
|
|||||||
// autopilot.ChannelController interface.
|
// autopilot.ChannelController interface.
|
||||||
var _ autopilot.ChannelController = (*chanController)(nil)
|
var _ autopilot.ChannelController = (*chanController)(nil)
|
||||||
|
|
||||||
// initAutoPilot initializes a new autopilot.ManagerCfg to manage an
|
// initAutoPilot initializes a new autopilot.ManagerCfg to manage an autopilot.
|
||||||
// autopilot.Agent instance based on the passed configuration struct. The agent
|
// Agent instance based on the passed configuration structs. The agent and all
|
||||||
// and all interfaces needed to drive it won't be launched before the Manager's
|
// interfaces needed to drive it won't be launched before the Manager's
|
||||||
// StartAgent method is called.
|
// 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, "+
|
atplLog.Infof("Instantiating autopilot with max_channels=%d, allocation=%f, "+
|
||||||
"min_chan_size=%d, max_chan_size=%d, private=%t, min_confs=%d, "+
|
"min_chan_size=%d, max_chan_size=%d, private=%t, min_confs=%d, "+
|
||||||
"conf_target=%d", cfg.MaxChannels, cfg.Allocation, cfg.MinChannelSize,
|
"conf_target=%d", cfg.MaxChannels, cfg.Allocation, cfg.MinChannelSize,
|
||||||
@ -173,10 +173,11 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.ManagerCfg, er
|
|||||||
Self: self,
|
Self: self,
|
||||||
Heuristic: weightedAttachment,
|
Heuristic: weightedAttachment,
|
||||||
ChanController: &chanController{
|
ChanController: &chanController{
|
||||||
server: svr,
|
server: svr,
|
||||||
private: cfg.Private,
|
private: cfg.Private,
|
||||||
minConfs: cfg.MinConfs,
|
minConfs: cfg.MinConfs,
|
||||||
confTarget: cfg.ConfTarget,
|
confTarget: cfg.ConfTarget,
|
||||||
|
chanMinHtlcIn: chainCfg.MinHTLCIn,
|
||||||
},
|
},
|
||||||
WalletBalance: func() (btcutil.Amount, error) {
|
WalletBalance: func() (btcutil.Amount, error) {
|
||||||
return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs)
|
return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs)
|
||||||
|
Loading…
Reference in New Issue
Block a user