mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-21 14:04:06 +01:00
routing: Call the function to update routing config on main cfg
NewMissionControl propagate the callback function defined on server.go and SetConfig call it to update the infos on main cfg.
This commit is contained in:
parent
77c7f776d5
commit
de495534e4
1 changed files with 22 additions and 5 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
|
@ -110,6 +111,10 @@ type MissionControl struct {
|
|||
// results that mission control collects.
|
||||
estimator Estimator
|
||||
|
||||
// onConfigUpdate is a function that is called whenever the
|
||||
// mission control state is updated.
|
||||
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
|
||||
|
||||
sync.Mutex
|
||||
|
||||
// TODO(roasbeef): further counters, if vertex continually unavailable,
|
||||
|
@ -124,6 +129,10 @@ type MissionControlConfig struct {
|
|||
// Estimator gives probability estimates for node pairs.
|
||||
Estimator Estimator
|
||||
|
||||
// OnConfigUpdate is function that is called whenever the
|
||||
// mission control state is updated.
|
||||
OnConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
|
||||
|
||||
// MaxMcHistory defines the maximum number of payment results that are
|
||||
// held on disk.
|
||||
MaxMcHistory int
|
||||
|
@ -224,11 +233,14 @@ func NewMissionControl(db kvdb.Backend, self route.Vertex,
|
|||
}
|
||||
|
||||
mc := &MissionControl{
|
||||
state: newMissionControlState(cfg.MinFailureRelaxInterval),
|
||||
now: time.Now,
|
||||
selfNode: self,
|
||||
store: store,
|
||||
estimator: cfg.Estimator,
|
||||
state: newMissionControlState(
|
||||
cfg.MinFailureRelaxInterval,
|
||||
),
|
||||
now: time.Now,
|
||||
selfNode: self,
|
||||
store: store,
|
||||
estimator: cfg.Estimator,
|
||||
onConfigUpdate: cfg.OnConfigUpdate,
|
||||
}
|
||||
|
||||
if err := mc.init(); err != nil {
|
||||
|
@ -308,6 +320,11 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
|
|||
m.state.minFailureRelaxInterval = cfg.MinFailureRelaxInterval
|
||||
m.estimator = cfg.Estimator
|
||||
|
||||
// Execute the callback function if it is set.
|
||||
m.onConfigUpdate.WhenSome(func(f func(cfg *MissionControlConfig)) {
|
||||
f(cfg)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue