lnd+pilot: use WeightedCombAttachment
We make the default autopilot agent use the WeightedCombAttachment. Currently it uses only one sub-heuristic, prefAttachment.
This commit is contained in:
parent
bdbadeaa75
commit
f48c8f91c4
9
lnd.go
9
lnd.go
@ -313,10 +313,15 @@ func lndMain() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set up an auotpilot 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
|
||||
// it at will.
|
||||
atplCfg := initAutoPilot(server, cfg.Autopilot)
|
||||
atplCfg, err := initAutoPilot(server, cfg.Autopilot)
|
||||
if err != nil {
|
||||
ltndLog.Errorf("unable to init autopilot: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
atplManager, err := autopilot.NewManager(atplCfg)
|
||||
if err != nil {
|
||||
ltndLog.Errorf("unable to create autopilot manager: %v", err)
|
||||
|
16
pilot.go
16
pilot.go
@ -83,7 +83,7 @@ var _ autopilot.ChannelController = (*chanController)(nil)
|
||||
// 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
|
||||
// StartAgent method is called.
|
||||
func initAutoPilot(svr *server, cfg *autoPilotConfig) *autopilot.ManagerCfg {
|
||||
func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.ManagerCfg, error) {
|
||||
atplLog.Infof("Instantiating autopilot with cfg: %v", spew.Sdump(cfg))
|
||||
|
||||
// Set up the constraints the autopilot heuristics must adhere to.
|
||||
@ -98,12 +98,22 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) *autopilot.ManagerCfg {
|
||||
// First, we'll create the preferential attachment heuristic.
|
||||
prefAttachment := autopilot.NewPrefAttachment()
|
||||
|
||||
weightedAttachment, err := autopilot.NewWeightedCombAttachment(
|
||||
&autopilot.WeightedHeuristic{
|
||||
Weight: 1.0,
|
||||
AttachmentHeuristic: prefAttachment,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// With the heuristic itself created, we can now populate the remainder
|
||||
// of the items that the autopilot agent needs to perform its duties.
|
||||
self := svr.identityPriv.PubKey()
|
||||
pilotCfg := autopilot.Config{
|
||||
Self: self,
|
||||
Heuristic: prefAttachment,
|
||||
Heuristic: weightedAttachment,
|
||||
ChanController: &chanController{
|
||||
server: svr,
|
||||
private: cfg.Private,
|
||||
@ -202,5 +212,5 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) *autopilot.ManagerCfg {
|
||||
},
|
||||
SubscribeTransactions: svr.cc.wallet.SubscribeTransactions,
|
||||
SubscribeTopology: svr.chanRouter.SubscribeTopology,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user