Skip to content

Commit ceea1a7

Browse files
committed
Merge branch 'develop'
2 parents 2f2dd80 + eae0927 commit ceea1a7

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

core/chain_manager.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"math/big"
8+
"os"
89
"runtime"
910
"sync"
1011
"time"
@@ -233,14 +234,23 @@ func (bc *ChainManager) setLastState() {
233234
data, _ := bc.blockDb.Get([]byte("LastBlock"))
234235
if len(data) != 0 {
235236
block := bc.GetBlock(common.BytesToHash(data))
236-
bc.currentBlock = block
237-
bc.lastBlockHash = block.Hash()
238-
239-
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
240-
bc.td = common.BigD(bc.blockDb.LastKnownTD())
237+
if block != nil {
238+
bc.currentBlock = block
239+
bc.lastBlockHash = block.Hash()
240+
} else { // TODO CLEAN THIS UP TMP CODE
241+
block = bc.GetBlockByNumber(400000)
242+
if block == nil {
243+
fmt.Println("Fatal. LastBlock not found. Report this issue")
244+
os.Exit(1)
245+
}
246+
bc.currentBlock = block
247+
bc.lastBlockHash = block.Hash()
248+
bc.insert(block)
249+
}
241250
} else {
242251
bc.Reset()
243252
}
253+
bc.td = bc.currentBlock.Td
244254
bc.currentGasLimit = CalcGasLimit(bc.currentBlock)
245255

246256
if glog.V(logger.Info) {
@@ -471,7 +481,7 @@ func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks [
471481
}
472482

473483
func (bc *ChainManager) setTotalDifficulty(td *big.Int) {
474-
bc.blockDb.Put([]byte("LTD"), td.Bytes())
484+
//bc.blockDb.Put([]byte("LTD"), td.Bytes())
475485
bc.td = td
476486
}
477487

0 commit comments

Comments
 (0)