mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
lnd: require blocks to be synced in regtest/simnet
This commit is contained in:
92
lnd.go
92
lnd.go
@@ -915,56 +915,52 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
||||
return err
|
||||
}
|
||||
|
||||
// If we're not in regtest or simnet mode, We'll wait until we're fully
|
||||
// synced to continue the start up of the remainder of the daemon. This
|
||||
// ensures that we don't accept any possibly invalid state transitions, or
|
||||
// accept channels with spent funds.
|
||||
if !(cfg.Bitcoin.RegTest || cfg.Bitcoin.SimNet ||
|
||||
cfg.Litecoin.RegTest || cfg.Litecoin.SimNet) {
|
||||
|
||||
_, bestHeight, err := activeChainControl.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine chain tip: %v",
|
||||
err)
|
||||
ltndLog.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
ltndLog.Infof("Waiting for chain backend to finish sync, "+
|
||||
"start_height=%v", bestHeight)
|
||||
|
||||
for {
|
||||
if !interceptor.Alive() {
|
||||
return nil
|
||||
}
|
||||
|
||||
synced, _, err := activeChainControl.Wallet.IsSynced()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine if "+
|
||||
"wallet is synced: %v", err)
|
||||
ltndLog.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if synced {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
_, bestHeight, err = activeChainControl.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine chain tip: %v",
|
||||
err)
|
||||
ltndLog.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
ltndLog.Infof("Chain backend is fully synced (end_height=%v)!",
|
||||
bestHeight)
|
||||
// We'll wait until we're fully synced to continue the start up of the
|
||||
// remainder of the daemon. This ensures that we don't accept any
|
||||
// possibly invalid state transitions, or accept channels with spent
|
||||
// funds.
|
||||
_, bestHeight, err := activeChainControl.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine chain tip: %v",
|
||||
err)
|
||||
ltndLog.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
ltndLog.Infof("Waiting for chain backend to finish sync, "+
|
||||
"start_height=%v", bestHeight)
|
||||
|
||||
for {
|
||||
if !interceptor.Alive() {
|
||||
return nil
|
||||
}
|
||||
|
||||
synced, _, err := activeChainControl.Wallet.IsSynced()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine if "+
|
||||
"wallet is synced: %v", err)
|
||||
ltndLog.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if synced {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
_, bestHeight, err = activeChainControl.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine chain tip: %v",
|
||||
err)
|
||||
ltndLog.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
ltndLog.Infof("Chain backend is fully synced (end_height=%v)!",
|
||||
bestHeight)
|
||||
|
||||
// With all the relevant chains initialized, we can finally start the
|
||||
// server itself.
|
||||
if err := server.Start(); err != nil {
|
||||
|
Reference in New Issue
Block a user