aboutsummaryrefslogtreecommitdiffstats
path: root/light/txpool.go
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2018-07-02 16:16:30 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-07-02 16:16:30 +0800
commita4a2343cdc1946e38da1aea1476642d1744c1354 (patch)
treec01c563224aaf34a1a391665bcca0b693b9cf0ce /light/txpool.go
parentfdfd6d3c3963b1b3459e4625458495458b11e8a7 (diff)
downloadgo-tangerine-a4a2343cdc1946e38da1aea1476642d1744c1354.tar
go-tangerine-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.gz
go-tangerine-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.bz2
go-tangerine-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.lz
go-tangerine-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.xz
go-tangerine-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.zst
go-tangerine-a4a2343cdc1946e38da1aea1476642d1744c1354.zip
ethdb, core: implement delete for db batch (#17101)
Diffstat (limited to 'light/txpool.go')
-rw-r--r--light/txpool.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/light/txpool.go b/light/txpool.go
index 5b4d06d90..767a797bd 100644
--- a/light/txpool.go
+++ b/light/txpool.go
@@ -199,15 +199,17 @@ func (pool *TxPool) checkMinedTxs(ctx context.Context, hash common.Hash, number
// rollbackTxs marks the transactions contained in recently rolled back blocks
// as rolled back. It also removes any positional lookup entries.
func (pool *TxPool) rollbackTxs(hash common.Hash, txc txStateChanges) {
+ batch := pool.chainDb.NewBatch()
if list, ok := pool.mined[hash]; ok {
for _, tx := range list {
txHash := tx.Hash()
- rawdb.DeleteTxLookupEntry(pool.chainDb, txHash)
+ rawdb.DeleteTxLookupEntry(batch, txHash)
pool.pending[txHash] = tx
txc.setState(txHash, false)
}
delete(pool.mined, hash)
}
+ batch.Write()
}
// reorgOnNewHead sets a new head header, processing (and rolling back if necessary)
@@ -504,14 +506,16 @@ func (self *TxPool) Content() (map[common.Address]types.Transactions, map[common
func (self *TxPool) RemoveTransactions(txs types.Transactions) {
self.mu.Lock()
defer self.mu.Unlock()
+
var hashes []common.Hash
+ batch := self.chainDb.NewBatch()
for _, tx := range txs {
- //self.RemoveTx(tx.Hash())
hash := tx.Hash()
delete(self.pending, hash)
- self.chainDb.Delete(hash[:])
+ batch.Delete(hash.Bytes())
hashes = append(hashes, hash)
}
+ batch.Write()
self.relay.Discard(hashes)
}