Skip to content

Commit 680e0c7

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 d090080 commit 680e0c7

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ 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"`
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+
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."`
195196

196197
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"`
197198
Faraday *faraday.Config `group:"Integrated faraday options (use when faraday-mode=integrated)" namespace:"faraday"`
@@ -312,6 +313,7 @@ func defaultConfig() *Config {
312313
Network: DefaultNetwork,
313314
LndMode: DefaultLndMode,
314315
Lnd: &lndDefaultConfig,
316+
LndConnectInterval: defaultStartupTimeout,
315317
LitDir: DefaultLitDir,
316318
LetsEncryptListen: defaultLetsEncryptListen,
317319
LetsEncryptDir: defaultLetsEncryptDir,

terminal.go

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

812-
case <-time.After(defaultStartupTimeout):
812+
case <-time.After(g.cfg.LndConnectInterval):
813813
return nil
814814
}
815815
}
@@ -891,16 +891,19 @@ func (g *LightningTerminal) setUpLNDClients(lndQuit chan struct{}) error {
891891
for {
892892
g.lndClient, err = lndclient.NewLndServices(
893893
&lndclient.LndServicesConfig{
894-
LndAddress: host,
895-
Network: network,
896-
TLSPath: tlsPath,
897-
Insecure: insecure,
898-
CustomMacaroonPath: macPath,
899-
CustomMacaroonHex: hex.EncodeToString(macData),
894+
LndAddress: host,
895+
Network: network,
896+
TLSPath: tlsPath,
897+
Insecure: insecure,
898+
CustomMacaroonPath: macPath,
899+
CustomMacaroonHex: hex.EncodeToString(
900+
macData,
901+
),
900902
BlockUntilChainSynced: true,
901903
BlockUntilUnlocked: true,
902904
CallerCtx: ctxc,
903905
CheckVersion: minimalCompatibleVersion,
906+
ChainSyncPollInterval: g.cfg.LndConnectInterval,
904907
},
905908
)
906909
if err == nil {

0 commit comments

Comments
 (0)