lnd: require blocks to be synced in regtest/simnet

This commit is contained in:
yyforyongyu
2021-08-18 02:55:00 +08:00
parent b0f3a08f2d
commit acdcf322b1

12
lnd.go
View File

@@ -915,13 +915,10 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
return err return err
} }
// If we're not in regtest or simnet mode, We'll wait until we're fully // We'll wait until we're fully synced to continue the start up of the
// synced to continue the start up of the remainder of the daemon. This // remainder of the daemon. This ensures that we don't accept any
// ensures that we don't accept any possibly invalid state transitions, or // possibly invalid state transitions, or accept channels with spent
// accept channels with spent funds. // funds.
if !(cfg.Bitcoin.RegTest || cfg.Bitcoin.SimNet ||
cfg.Litecoin.RegTest || cfg.Litecoin.SimNet) {
_, bestHeight, err := activeChainControl.ChainIO.GetBestBlock() _, bestHeight, err := activeChainControl.ChainIO.GetBestBlock()
if err != nil { if err != nil {
err := fmt.Errorf("unable to determine chain tip: %v", err := fmt.Errorf("unable to determine chain tip: %v",
@@ -963,7 +960,6 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
ltndLog.Infof("Chain backend is fully synced (end_height=%v)!", ltndLog.Infof("Chain backend is fully synced (end_height=%v)!",
bestHeight) bestHeight)
}
// With all the relevant chains initialized, we can finally start the // With all the relevant chains initialized, we can finally start the
// server itself. // server itself.