mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
Merge 14047eca3d into 55bdcfaeac
This commit is contained in:
commit
82c86a9e0a
1 changed files with 9 additions and 18 deletions
|
|
@ -226,20 +226,16 @@ func (bc *ChainManager) recover() bool {
|
||||||
|
|
||||||
func (bc *ChainManager) setLastState() error {
|
func (bc *ChainManager) setLastState() error {
|
||||||
head := GetHeadBlockHash(bc.chainDb)
|
head := GetHeadBlockHash(bc.chainDb)
|
||||||
if head != (common.Hash{}) {
|
block := bc.GetBlock(head)
|
||||||
block := bc.GetBlock(head)
|
if block != nil {
|
||||||
if block != nil {
|
bc.currentBlock = block
|
||||||
bc.currentBlock = block
|
|
||||||
} else {
|
|
||||||
glog.Infof("LastBlock (%x) not found. Recovering...\n", head)
|
|
||||||
if bc.recover() {
|
|
||||||
glog.Infof("Recover successful")
|
|
||||||
} else {
|
|
||||||
glog.Fatalf("Recover failed. Please report")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bc.Reset()
|
glog.Infof("LastBlock (%x) not found. Recovering...\n", head)
|
||||||
|
if bc.recover() {
|
||||||
|
glog.Infof("Recover successful")
|
||||||
|
} else {
|
||||||
|
glog.Fatalf("Recover failed. Please report")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bc.td = bc.GetTd(bc.currentBlock.Hash())
|
bc.td = bc.GetTd(bc.currentBlock.Hash())
|
||||||
bc.currentGasLimit = CalcGasLimit(bc.currentBlock)
|
bc.currentGasLimit = CalcGasLimit(bc.currentBlock)
|
||||||
|
|
@ -251,11 +247,6 @@ func (bc *ChainManager) setLastState() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset purges the entire blockchain, restoring it to its genesis state.
|
|
||||||
func (bc *ChainManager) Reset() {
|
|
||||||
bc.ResetWithGenesisBlock(bc.genesisBlock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetWithGenesisBlock purges the entire blockchain, restoring it to the
|
// ResetWithGenesisBlock purges the entire blockchain, restoring it to the
|
||||||
// specified genesis state.
|
// specified genesis state.
|
||||||
func (bc *ChainManager) ResetWithGenesisBlock(genesis *types.Block) {
|
func (bc *ChainManager) ResetWithGenesisBlock(genesis *types.Block) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue