|
|
|
@ -180,7 +180,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par |
|
|
|
|
if cacheConfig == nil { |
|
|
|
|
cacheConfig = &CacheConfig{ |
|
|
|
|
TrieNodeLimit: 256 * 1024 * 1024, |
|
|
|
|
TrieTimeLimit: 5 * time.Minute, |
|
|
|
|
TrieTimeLimit: 2 * time.Minute, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bodyCache, _ := lru.New(bodyCacheLimit) |
|
|
|
@ -326,13 +326,15 @@ func (bc *BlockChain) loadLastState() error { |
|
|
|
|
// Everything seems to be fine, set as the head block
|
|
|
|
|
bc.currentBlock.Store(currentBlock) |
|
|
|
|
|
|
|
|
|
// We don't need the following as we want the current header and block to be consistent
|
|
|
|
|
// Restore the last known head header
|
|
|
|
|
//currentHeader := currentBlock.Header()
|
|
|
|
|
//if head := rawdb.ReadHeadHeaderHash(bc.db); head != (common.Hash{}) {
|
|
|
|
|
// if header := bc.GetHeaderByHash(head); header != nil {
|
|
|
|
|
// currentHeader = header
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
currentHeader := currentBlock.Header() |
|
|
|
|
if head := rawdb.ReadHeadHeaderHash(bc.db); head != (common.Hash{}) { |
|
|
|
|
if header := bc.GetHeaderByHash(head); header != nil { |
|
|
|
|
currentHeader = header |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bc.hc.SetCurrentHeader(currentHeader) |
|
|
|
|
|
|
|
|
|
// Restore the last known head fast block
|
|
|
|
@ -555,6 +557,11 @@ func (bc *BlockChain) repair(head **types.Block) error { |
|
|
|
|
Msg("Rewound blockchain to past state") |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
// Repair last commit sigs
|
|
|
|
|
lastSig := (*head).Header().LastCommitSignature() |
|
|
|
|
sigAndBitMap := append(lastSig[:], (*head).Header().LastCommitBitmap()...) |
|
|
|
|
bc.WriteLastCommits(sigAndBitMap) |
|
|
|
|
|
|
|
|
|
// Otherwise rewind one block and recheck state availability there
|
|
|
|
|
(*head) = bc.GetBlock((*head).ParentHash(), (*head).NumberU64()-1) |
|
|
|
|
} |
|
|
|
|