Skip to content

Commit 4ec62b1

Browse files
committed
lnd: Create the callback function to update the estimator info on main cfg
Create the callback function (UpdateRoutingConfig) to update the estimator info on main cfg. The callback function is a parameter on NewMissionControl function.
1 parent 4c099ce commit 4ec62b1

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

rpcserver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6928,6 +6928,10 @@ func (r *rpcServer) DebugLevel(ctx context.Context,
69286928
if err != nil {
69296929
return nil, err
69306930
}
6931+
6932+
// There is no error parsing the LevelSpec, so we'll update
6933+
// the current debug level, without checking everything again.
6934+
r.cfg.DebugLevel = req.LevelSpec
69316935

69326936
return &lnrpc.DebugLevelResponse{}, nil
69336937
}

server.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,12 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
923923
routingConfig.ProbabilityEstimatorType)
924924
}
925925
}
926-
926+
927+
// UpdateRoutingConfig is a function that will be called by the
928+
// mission control instance every time a new estimator value
929+
// is setted.
927930
mcCfg := &routing.MissionControlConfig{
931+
UpdateEstimator: s.UpdateRoutingConfig,
928932
Estimator: estimator,
929933
MaxMcHistory: routingConfig.MaxMcHistory,
930934
McFlushInterval: routingConfig.McFlushInterval,
@@ -1680,6 +1684,33 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
16801684
return s, nil
16811685
}
16821686

1687+
// UpdateRoutingConfig is a callback function to update the routing config
1688+
// values in the main cfg when the lncli setmccfg is called.
1689+
func (s *server) UpdateRoutingConfig(estimator routing.Estimator) {
1690+
routerCfg := s.cfg.SubRPCServers.RouterRPC
1691+
1692+
switch c := estimator.Config().(type) {
1693+
case routing.AprioriConfig:
1694+
routerCfg.ProbabilityEstimatorType =
1695+
routing.AprioriEstimatorName
1696+
1697+
targetCfg := s.cfg.SubRPCServers.RouterRPC.AprioriConfig
1698+
targetCfg.PenaltyHalfLife = c.PenaltyHalfLife
1699+
targetCfg.Weight = c.AprioriWeight
1700+
targetCfg.CapacityFraction = c.CapacityFraction
1701+
targetCfg.HopProbability = c.AprioriHopProbability
1702+
1703+
case routing.BimodalConfig:
1704+
routerCfg.ProbabilityEstimatorType =
1705+
routing.BimodalEstimatorName
1706+
1707+
targetCfg := s.cfg.SubRPCServers.RouterRPC.BimodalConfig
1708+
targetCfg.Scale = int64(c.BimodalScaleMsat)
1709+
targetCfg.NodeWeight = c.BimodalNodeWeight
1710+
targetCfg.DecayTime = c.BimodalDecayTime
1711+
}
1712+
}
1713+
16831714
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
16841715
// used for option_scid_alias channels where the ChannelUpdate to be sent back
16851716
// may differ from what is on disk.

0 commit comments

Comments
 (0)