diff --git a/core/blockchain.go b/core/blockchain.go index f083f53e04..590e05e0a8 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -329,6 +329,8 @@ func (bc *BlockChain) loadLastState() error { if head == (common.Hash{}) { // Corrupt or empty database, init from scratch log.Warn("Empty database, resetting chain") + bc.chainmu.Unlock() + defer bc.chainmu.Lock() return bc.Reset() } // Make sure the entire head block is available @@ -336,6 +338,8 @@ func (bc *BlockChain) loadLastState() error { if currentBlock == nil { // Corrupt or empty database, init from scratch log.Warn("Head block missing, resetting chain", "hash", head) + bc.chainmu.Unlock() + defer bc.chainmu.Lock() return bc.Reset() } // Make sure the state associated with the block is available diff --git a/light/lightchain.go b/light/lightchain.go index 636e06f518..88bea4fead 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -153,7 +153,9 @@ func (lc *LightChain) HeaderChain() *core.HeaderChain { func (lc *LightChain) loadLastState() error { if head := rawdb.ReadHeadHeaderHash(lc.chainDb); head == (common.Hash{}) { // Corrupt or empty database, init from scratch + lc.chainmu.Unlock() lc.Reset() + lc.chainmu.Lock() } else { if header := lc.GetHeaderByHash(head); header != nil { lc.hc.SetCurrentHeader(header)