From ea4ef204a0836724b8564ae9d74cfe8e0d7261ad Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 7 May 2021 19:11:20 +0200 Subject: [PATCH] rpcserver: add router synced to synced_to_chain flag The router has a lot of work to do for each block. So it might be possible that it isn't yet up to date with the most recent block, even if the wallet is. This can happen in environments with high CPU load (such as parallel itests). Since the `synced_to_chain` flag in the response of this call is used by many wallets (and also our itests) to make sure everything's up to date, we add the router's state to it. So the flag will only toggle to true once the router was also able to catch up. --- rpcserver.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index 1bb95aa0..611fb5d7 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2507,6 +2507,17 @@ func (r *rpcServer) GetInfo(ctx context.Context, "with current best block in the main chain: %v", err) } + // The router has a lot of work to do for each block. So it might be + // possible that it isn't yet up to date with the most recent block, + // even if the wallet is. This can happen in environments with high CPU + // load (such as parallel itests). Since the `synced_to_chain` flag in + // the response of this call is used by many wallets (and also our + // itests) to make sure everything's up to date, we add the router's + // state to it. So the flag will only toggle to true once the router was + // also able to catch up. + routerHeight := r.server.chanRouter.SyncedHeight() + isSynced = isSynced && uint32(bestHeight) == routerHeight + network := lncfg.NormalizeNetwork(r.cfg.ActiveNetParams.Name) activeChains := make([]*lnrpc.Chain, r.cfg.registeredChains.NumActiveChains()) for i, chain := range r.cfg.registeredChains.ActiveChains() {