|
|
|
@ -576,7 +576,7 @@ func (bc *BlockChain) SetHead(head uint64) error { |
|
|
|
|
header := bc.CurrentBlock() |
|
|
|
|
block := bc.GetBlock(header.Hash(), header.Number.Uint64()) |
|
|
|
|
if block == nil { |
|
|
|
|
// This should never happen. In practice, previsouly currentBlock
|
|
|
|
|
// This should never happen. In practice, previously currentBlock
|
|
|
|
|
// contained the entire block whereas now only a "marker", so there
|
|
|
|
|
// is an ever so slight chance for a race we should handle.
|
|
|
|
|
log.Error("Current block not found in database", "block", header.Number, "hash", header.Hash()) |
|
|
|
@ -598,7 +598,7 @@ func (bc *BlockChain) SetHeadWithTimestamp(timestamp uint64) error { |
|
|
|
|
header := bc.CurrentBlock() |
|
|
|
|
block := bc.GetBlock(header.Hash(), header.Number.Uint64()) |
|
|
|
|
if block == nil { |
|
|
|
|
// This should never happen. In practice, previsouly currentBlock
|
|
|
|
|
// This should never happen. In practice, previously currentBlock
|
|
|
|
|
// contained the entire block whereas now only a "marker", so there
|
|
|
|
|
// is an ever so slight chance for a race we should handle.
|
|
|
|
|
log.Error("Current block not found in database", "block", header.Number, "hash", header.Hash()) |
|
|
|
@ -982,7 +982,7 @@ func (bc *BlockChain) stopWithoutSaving() { |
|
|
|
|
func (bc *BlockChain) Stop() { |
|
|
|
|
bc.stopWithoutSaving() |
|
|
|
|
|
|
|
|
|
// Ensure that the entirety of the state snapshot is journalled to disk.
|
|
|
|
|
// Ensure that the entirety of the state snapshot is journaled to disk.
|
|
|
|
|
var snapBase common.Hash |
|
|
|
|
if bc.snaps != nil { |
|
|
|
|
var err error |
|
|
|
@ -1193,7 +1193,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ |
|
|
|
|
// a background routine to re-indexed all indices in [ancients - txlookupLimit, ancients)
|
|
|
|
|
// range. In this case, all tx indices of newly imported blocks should be
|
|
|
|
|
// generated.
|
|
|
|
|
var batch = bc.db.NewBatch() |
|
|
|
|
batch := bc.db.NewBatch() |
|
|
|
|
for i, block := range blockChain { |
|
|
|
|
if bc.txLookupLimit == 0 || ancientLimit <= bc.txLookupLimit || block.NumberU64() >= ancientLimit-bc.txLookupLimit { |
|
|
|
|
rawdb.WriteTxLookupEntriesByBlock(batch, block) |
|
|
|
@ -2585,7 +2585,7 @@ func (bc *BlockChain) SetTrieFlushInterval(interval time.Duration) { |
|
|
|
|
bc.flushInterval.Store(int64(interval)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetTrieFlushInterval gets the in-memroy tries flush interval
|
|
|
|
|
// GetTrieFlushInterval gets the in-memory tries flush interval
|
|
|
|
|
func (bc *BlockChain) GetTrieFlushInterval() time.Duration { |
|
|
|
|
return time.Duration(bc.flushInterval.Load()) |
|
|
|
|
} |
|
|
|
|