mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
lnd: Create a callback function (UpdatingRoutingConfig)
This callback function is called whenever the command `lncli setmccfg` is used to change the routing settings.
This commit is contained in:
parent
de495534e4
commit
b08e65ec85
30
server.go
30
server.go
@ -928,6 +928,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
}
|
||||
|
||||
mcCfg := &routing.MissionControlConfig{
|
||||
OnConfigUpdate: fn.Some(s.UpdateRoutingConfig),
|
||||
Estimator: estimator,
|
||||
MaxMcHistory: routingConfig.MaxMcHistory,
|
||||
McFlushInterval: routingConfig.McFlushInterval,
|
||||
@ -1699,6 +1700,35 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// UpdateRoutingConfig is a callback function to update the routing config
|
||||
// values in the main cfg.
|
||||
func (s *server) UpdateRoutingConfig(cfg *routing.MissionControlConfig) {
|
||||
routerCfg := s.cfg.SubRPCServers.RouterRPC
|
||||
|
||||
switch c := cfg.Estimator.Config().(type) {
|
||||
case routing.AprioriConfig:
|
||||
routerCfg.ProbabilityEstimatorType =
|
||||
routing.AprioriEstimatorName
|
||||
|
||||
targetCfg := routerCfg.AprioriConfig
|
||||
targetCfg.PenaltyHalfLife = c.PenaltyHalfLife
|
||||
targetCfg.Weight = c.AprioriWeight
|
||||
targetCfg.CapacityFraction = c.CapacityFraction
|
||||
targetCfg.HopProbability = c.AprioriHopProbability
|
||||
|
||||
case routing.BimodalConfig:
|
||||
routerCfg.ProbabilityEstimatorType =
|
||||
routing.BimodalEstimatorName
|
||||
|
||||
targetCfg := routerCfg.BimodalConfig
|
||||
targetCfg.Scale = int64(c.BimodalScaleMsat)
|
||||
targetCfg.NodeWeight = c.BimodalNodeWeight
|
||||
targetCfg.DecayTime = c.BimodalDecayTime
|
||||
}
|
||||
|
||||
routerCfg.MaxMcHistory = cfg.MaxMcHistory
|
||||
}
|
||||
|
||||
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
|
||||
// used for option_scid_alias channels where the ChannelUpdate to be sent back
|
||||
// may differ from what is on disk.
|
||||
|
Loading…
Reference in New Issue
Block a user