This commit is contained in:
Gustav Simonsson 2015-09-15 14:25:24 +00:00
commit 82c86a9e0a

View file

@ -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) {