Skip to content

Commit 6f6161e

Browse files
committed
lnd: Create a callback function (UpdatingRoutingConfig)
This callback function is called whenever the command `lncli setmccfg` is used to change the routing settings.
1 parent 61940df commit 6f6161e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

server.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
929929
}
930930

931931
mcCfg := &routing.MissionControlConfig{
932+
OnConfigUpdate: fn.Some(s.UpdateRoutingConfig),
932933
Estimator: estimator,
933934
MaxMcHistory: routingConfig.MaxMcHistory,
934935
McFlushInterval: routingConfig.McFlushInterval,
@@ -1699,6 +1700,35 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
16991700
return s, nil
17001701
}
17011702

1703+
// UpdateRoutingConfig is a callback function to update the routing config
1704+
// values in the main cfg.
1705+
func (s *server) UpdateRoutingConfig(cfg *routing.MissionControlConfig) {
1706+
routerCfg := s.cfg.SubRPCServers.RouterRPC
1707+
1708+
switch c := cfg.Estimator.Config().(type) {
1709+
case routing.AprioriConfig:
1710+
routerCfg.ProbabilityEstimatorType =
1711+
routing.AprioriEstimatorName
1712+
1713+
targetCfg := routerCfg.AprioriConfig
1714+
targetCfg.PenaltyHalfLife = c.PenaltyHalfLife
1715+
targetCfg.Weight = c.AprioriWeight
1716+
targetCfg.CapacityFraction = c.CapacityFraction
1717+
targetCfg.HopProbability = c.AprioriHopProbability
1718+
1719+
case routing.BimodalConfig:
1720+
routerCfg.ProbabilityEstimatorType =
1721+
routing.BimodalEstimatorName
1722+
1723+
targetCfg := routerCfg.BimodalConfig
1724+
targetCfg.Scale = int64(c.BimodalScaleMsat)
1725+
targetCfg.NodeWeight = c.BimodalNodeWeight
1726+
targetCfg.DecayTime = c.BimodalDecayTime
1727+
}
1728+
1729+
routerCfg.MaxMcHistory = cfg.MaxMcHistory
1730+
}
1731+
17021732
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
17031733
// used for option_scid_alias channels where the ChannelUpdate to be sent back
17041734
// may differ from what is on disk.

0 commit comments

Comments
 (0)