Skip to content

Commit 3f9a638

Browse files
committed
litd: allow faster startup by making re-try configurable
This change will speed up integration tests by not waiting a full 5 seconds before re-trying the connection to lnd if it fails the first time.
1 parent a027e40 commit 3f9a638

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ type Config struct {
190190
// friendly. Because then we can reference the explicit modes in the
191191
// help descriptions of the section headers. We'll parse the mode into
192192
// a bool for internal use for better code readability.
193-
LndMode string `long:"lnd-mode" description:"The mode to run lnd in, either 'remote' (default) or 'integrated'. 'integrated' means lnd is started alongside the UI and everything is stored in lnd's main data directory, configure everything by using the --lnd.* flags. 'remote' means the UI connects to an existing lnd node and acts as a proxy for gRPC calls to it. In the remote node LiT creates its own directory for log and configuration files, configure everything using the --remote.* flags." choice:"integrated" choice:"remote"`
194-
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`
195-
LndRPCTimeout time.Duration `long:"lndrpctimeout" description:"The timeout for RPC calls to lnd from other sub servers. This can be adjusted for slow lnd instances to give loop/pool/faraday/taproot-assets more time when querying into lnd's RPC methods. This value should NOT be set to anything below 30 seconds to avoid problems."`
193+
LndMode string `long:"lnd-mode" description:"The mode to run lnd in, either 'remote' (default) or 'integrated'. 'integrated' means lnd is started alongside the UI and everything is stored in lnd's main data directory, configure everything by using the --lnd.* flags. 'remote' means the UI connects to an existing lnd node and acts as a proxy for gRPC calls to it. In the remote node LiT creates its own directory for log and configuration files, configure everything using the --remote.* flags." choice:"integrated" choice:"remote"`
194+
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`
195+
LndRPCTimeout time.Duration `long:"lndrpctimeout" description:"The timeout for RPC calls to lnd from other sub servers. This can be adjusted for slow lnd instances to give loop/pool/faraday/taproot-assets more time when querying into lnd's RPC methods. This value should NOT be set to anything below 30 seconds to avoid problems."`
196+
LndConnectInterval time.Duration `long:"lndconnectinterval" hidden:"true" description:"The interval at which LiT tries to connect to the lnd node. This value should only be changed for development mode."`
196197

197198
FaradayMode string `long:"faraday-mode" description:"The mode to run faraday in, either 'integrated' (default), 'remote' or 'disable'. 'integrated' means faraday is started alongside the UI and everything is stored in faraday's main data directory, configure everything by using the --faraday.* flags. 'remote' means the UI connects to an existing faraday node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without faraday." choice:"integrated" choice:"remote" choice:"disable"`
198199
Faraday *faraday.Config `group:"Integrated faraday options (use when faraday-mode=integrated)" namespace:"faraday"`
@@ -314,6 +315,7 @@ func defaultConfig() *Config {
314315
LndMode: DefaultLndMode,
315316
Lnd: &lndDefaultConfig,
316317
LndRPCTimeout: defaultRPCTimeout,
318+
LndConnectInterval: defaultStartupTimeout,
317319
LitDir: DefaultLitDir,
318320
LetsEncryptListen: defaultLetsEncryptListen,
319321
LetsEncryptDir: defaultLetsEncryptDir,

terminal.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ func (g *LightningTerminal) setUpLNDClients(lndQuit chan struct{}) error {
811811
case <-interceptor.ShutdownChannel():
812812
return fmt.Errorf("received the shutdown signal")
813813

814-
case <-time.After(defaultStartupTimeout):
814+
case <-time.After(g.cfg.LndConnectInterval):
815815
return nil
816816
}
817817
}
@@ -893,17 +893,20 @@ func (g *LightningTerminal) setUpLNDClients(lndQuit chan struct{}) error {
893893
for {
894894
g.lndClient, err = lndclient.NewLndServices(
895895
&lndclient.LndServicesConfig{
896-
LndAddress: host,
897-
Network: network,
898-
TLSPath: tlsPath,
899-
Insecure: insecure,
900-
CustomMacaroonPath: macPath,
901-
CustomMacaroonHex: hex.EncodeToString(macData),
896+
LndAddress: host,
897+
Network: network,
898+
TLSPath: tlsPath,
899+
Insecure: insecure,
900+
CustomMacaroonPath: macPath,
901+
CustomMacaroonHex: hex.EncodeToString(
902+
macData,
903+
),
902904
BlockUntilChainSynced: true,
903905
BlockUntilUnlocked: true,
904906
CallerCtx: ctxc,
905907
CheckVersion: minimalCompatibleVersion,
906908
RPCTimeout: g.cfg.LndRPCTimeout,
909+
ChainSyncPollInterval: g.cfg.LndConnectInterval,
907910
},
908911
)
909912
if err == nil {

0 commit comments

Comments
 (0)