core, cmd/geth: recover by number

This commit is contained in:
Jeffrey Wilcke
2015-07-01 00:52:44 +02:00
parent be935bff84
commit 29ab1fa8a5
2 changed files with 34 additions and 2 deletions

View File

@ -238,6 +238,16 @@ func (self *ChainManager) setTransState(statedb *state.StateDB) {
self.transState = statedb
}
func (bc *ChainManager) Recover(num uint64) {
block := bc.GetBlockByNumber(num)
if block != nil {
bc.insert(block)
glog.Infof("Recovery succesful. New HEAD %x\n", block.Hash())
} else {
glog.Fatalln("Recovery failed")
}
}
func (bc *ChainManager) recover() bool {
data, _ := bc.blockDb.Get([]byte("checkpoint"))
if len(data) != 0 {
@ -261,8 +271,6 @@ func (bc *ChainManager) setLastState() {
if len(data) != 0 {
block := bc.GetBlock(common.BytesToHash(data))
if block != nil {
bc.blockDb.Put([]byte("checkpoint"), block.Hash().Bytes())
bc.currentBlock = block
bc.lastBlockHash = block.Hash()
} else {