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
|
||||
// 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)
|
||||
|
33
pilot.go
33
pilot.go
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user