Skip to content

Commit a8ac4cd

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 00741e7 commit a8ac4cd

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
@@ -186,8 +186,9 @@ type Config struct {
186186
// friendly. Because then we can reference the explicit modes in the
187187
// help descriptions of the section headers. We'll parse the mode into
188188
// a bool for internal use for better code readability.
189-
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"`
190-
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`
189+
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"`
190+
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`
191+
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."`
191192

192193
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"`
193194
Faraday *faraday.Config `group:"Integrated faraday options (use when faraday-mode=integrated)" namespace:"faraday"`
@@ -304,6 +305,7 @@ func defaultConfig() *Config {
304305
Network: DefaultNetwork,
305306
LndMode: DefaultLndMode,
306307
Lnd: &lndDefaultConfig,
308+
LndConnectInterval: defaultStartupTimeout,
307309
LitDir: DefaultLitDir,
308310
LetsEncryptListen: defaultLetsEncryptListen,
309311
LetsEncryptDir: defaultLetsEncryptDir,

terminal.go

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

767-
case <-time.After(defaultStartupTimeout):
767+
case <-time.After(g.cfg.LndConnectInterval):
768768
return nil
769769
}
770770
}
@@ -831,16 +831,19 @@ func (g *LightningTerminal) setUpLNDClients(lndQuit chan struct{}) error {
831831
for {
832832
g.lndClient, err = lndclient.NewLndServices(
833833
&lndclient.LndServicesConfig{
834-
LndAddress: host,
835-
Network: network,
836-
TLSPath: tlsPath,
837-
Insecure: insecure,
838-
CustomMacaroonPath: macPath,
839-
CustomMacaroonHex: hex.EncodeToString(macData),
834+
LndAddress: host,
835+
Network: network,
836+
TLSPath: tlsPath,
837+
Insecure: insecure,
838+
CustomMacaroonPath: macPath,
839+
CustomMacaroonHex: hex.EncodeToString(
840+
macData,
841+
),
840842
BlockUntilChainSynced: true,
841843
BlockUntilUnlocked: true,
842844
CallerCtx: ctxc,
843845
CheckVersion: minimalCompatibleVersion,
846+
ChainSyncPollInterval: g.cfg.LndConnectInterval,
844847
},
845848
)
846849
if err == nil {

0 commit comments

Comments
 (0)