aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 0b50e3f37..2f1e78423 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -269,8 +269,8 @@ func (bc *BlockChain) SetHead(head uint64) error {
defer bc.mu.Unlock()
// Rewind the header chain, deleting all block bodies until then
- delFn := func(hash common.Hash, num uint64) {
- rawdb.DeleteBody(bc.db, hash, num)
+ delFn := func(db rawdb.DatabaseDeleter, hash common.Hash, num uint64) {
+ rawdb.DeleteBody(db, hash, num)
}
bc.hc.SetHead(head, delFn)
currentHeader := bc.hc.CurrentHeader()
@@ -1340,9 +1340,12 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
diff := types.TxDifference(deletedTxs, addedTxs)
// When transactions get deleted from the database that means the
// receipts that were created in the fork must also be deleted
+ batch := bc.db.NewBatch()
for _, tx := range diff {
- rawdb.DeleteTxLookupEntry(bc.db, tx.Hash())
+ rawdb.DeleteTxLookupEntry(batch, tx.Hash())
}
+ batch.Write()
+
if len(deletedLogs) > 0 {
go bc.rmLogsFeed.Send(RemovedLogsEvent{deletedLogs})
}