mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core, light: add unlock before Reset to avoid double lock
This commit is contained in:
parent
34bb132b10
commit
1d7ee903e5
2 changed files with 6 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue