rpcserver: check router state only if it is validating
Fixes #5325. Corrects a problem introduced in #5281 that caused the synced_to_chain flag in the GetInfo call to never become true when the router subsystem is running in Neutrino mode (channel validation turned off).
This commit is contained in:
parent
f15961f764
commit
3f2d4f108d
27
rpcserver.go
27
rpcserver.go
@ -2470,8 +2470,8 @@ func (r *rpcServer) AbandonChannel(_ context.Context,
|
||||
// GetInfo returns general information concerning the lightning node including
|
||||
// its identity pubkey, alias, the chains it is connected to, and information
|
||||
// concerning the number of open+pending channels.
|
||||
func (r *rpcServer) GetInfo(ctx context.Context,
|
||||
in *lnrpc.GetInfoRequest) (*lnrpc.GetInfoResponse, error) {
|
||||
func (r *rpcServer) GetInfo(_ context.Context,
|
||||
_ *lnrpc.GetInfoRequest) (*lnrpc.GetInfoResponse, error) {
|
||||
|
||||
serverPeers := r.server.Peers()
|
||||
|
||||
@ -2511,16 +2511,18 @@ 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
|
||||
// If the router does full channel validation, it 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.
|
||||
if !r.cfg.Routing.AssumeChannelValid {
|
||||
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())
|
||||
@ -2529,7 +2531,6 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
||||
Chain: chain.String(),
|
||||
Network: network,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check if external IP addresses were provided to lnd and use them
|
||||
|
Loading…
Reference in New Issue
Block a user