diff --git a/server.go b/server.go index 555ee2627..fd746a85e 100644 --- a/server.go +++ b/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.