aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-01 06:52:44 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-01 06:52:44 +0800
commit29ab1fa8a50db8aa16c5d707f1cab7dc201a4053 (patch)
tree1339dbd873de83167526adfa4333225ad8aa7725 /core
parentbe935bff84d54cd7a7f4074e2326d62f664ba4e3 (diff)
downloaddexon-29ab1fa8a50db8aa16c5d707f1cab7dc201a4053.tar
dexon-29ab1fa8a50db8aa16c5d707f1cab7dc201a4053.tar.gz
dexon-29ab1fa8a50db8aa16c5d707f1cab7dc201a4053.tar.bz2
dexon-29ab1fa8a50db8aa16c5d707f1cab7dc201a4053.tar.lz
dexon-29ab1fa8a50db8aa16c5d707f1cab7dc201a4053.tar.xz
dexon-29ab1fa8a50db8aa16c5d707f1cab7dc201a4053.tar.zst
dexon-29ab1fa8a50db8aa16c5d707f1cab7dc201a4053.zip
core, cmd/geth: recover by number
Diffstat (limited to 'core')
-rw-r--r--core/chain_manager.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index c89aae3f0..247b5fdb3 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -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 {