@@ -923,8 +923,11 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
923923 routingConfig .ProbabilityEstimatorType )
924924 }
925925 }
926-
926+ // UpdateEstimatorValue is a function that will be called by the
927+ // mission control instance every time a new estimator value
928+ // is setted.
927929 mcCfg := & routing.MissionControlConfig {
930+ UpdateEstimatorCB : s .UpdateEstimatorValue ,
928931 Estimator : estimator ,
929932 MaxMcHistory : routingConfig .MaxMcHistory ,
930933 McFlushInterval : routingConfig .McFlushInterval ,
@@ -1680,6 +1683,29 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
16801683 return s , nil
16811684}
16821685
1686+ // UpdateEstimatorValue is a callback function to change estimator value in the
1687+ // main cfg when the lncli setmccfg is called to change the estimator value.
1688+ func (s * server ) UpdateEstimatorValue (estimator routing.Estimator ) {
1689+ switch c := estimator .Config ().(type ) {
1690+ case routing.AprioriConfig :
1691+ s .cfg .SubRPCServers .RouterRPC .RoutingConfig .ProbabilityEstimatorType =
1692+ routing .AprioriEstimatorName
1693+ targetCfg := s .cfg .SubRPCServers .RouterRPC .AprioriConfig
1694+ targetCfg .PenaltyHalfLife = c .PenaltyHalfLife
1695+ targetCfg .Weight = c .AprioriWeight
1696+ targetCfg .CapacityFraction = c .CapacityFraction
1697+ targetCfg .HopProbability = c .AprioriHopProbability
1698+
1699+ case routing.BimodalConfig :
1700+ s .cfg .SubRPCServers .RouterRPC .RoutingConfig .ProbabilityEstimatorType =
1701+ routing .BimodalEstimatorName
1702+ targetCfg := s .cfg .SubRPCServers .RouterRPC .BimodalConfig
1703+ targetCfg .Scale = int64 (c .BimodalScaleMsat )
1704+ targetCfg .NodeWeight = c .BimodalNodeWeight
1705+ targetCfg .DecayTime = c .BimodalDecayTime
1706+ }
1707+ }
1708+
16831709// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
16841710// used for option_scid_alias channels where the ChannelUpdate to be sent back
16851711// may differ from what is on disk.
0 commit comments