diff options
author | gary rong <garyrong0905@gmail.com> | 2018-07-02 16:16:30 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-07-02 16:16:30 +0800 |
commit | a4a2343cdc1946e38da1aea1476642d1744c1354 (patch) | |
tree | c01c563224aaf34a1a391665bcca0b693b9cf0ce /core/blockchain.go | |
parent | fdfd6d3c3963b1b3459e4625458495458b11e8a7 (diff) | |
download | dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.gz dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.bz2 dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.lz dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.xz dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.zst dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.zip |
ethdb, core: implement delete for db batch (#17101)
Diffstat (limited to 'core/blockchain.go')
-rw-r--r-- | core/blockchain.go | 9 |
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}) } |