aboutsummaryrefslogtreecommitdiffstats
path: root/core/transaction_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-30 06:20:59 +0800
committerobscuren <geffobscura@gmail.com>2015-04-30 06:20:59 +0800
commit88292f35db656fe0677a3d7cf9be3a78f507699d (patch)
treea5f5fd0ebcc01453d0f7e64a84881bd0753a53e1 /core/transaction_pool.go
parent2590a7dabbf6781734be0c388b46ecd53ece6155 (diff)
downloadgo-tangerine-88292f35db656fe0677a3d7cf9be3a78f507699d.tar.gz
go-tangerine-88292f35db656fe0677a3d7cf9be3a78f507699d.tar.zst
go-tangerine-88292f35db656fe0677a3d7cf9be3a78f507699d.zip
core: remove txs from queue in addition to removal of pending
Diffstat (limited to 'core/transaction_pool.go')
-rw-r--r--core/transaction_pool.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index 8543aa017..22a804e1d 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -306,6 +306,27 @@ func (pool *TxPool) checkQueue() {
}
}
+func (pool *TxPool) removeTx(hash common.Hash) {
+ // delete from pending pool
+ delete(pool.txs, hash)
+
+ // delete from queue
+out:
+ for address, txs := range pool.queue {
+ for i, tx := range txs {
+ if tx.Hash() == hash {
+ if len(txs) == 1 {
+ // if only one tx, remove entire address entry
+ delete(pool.queue, address)
+ } else {
+ pool.queue[address][len(txs)-1], pool.queue[address] = nil, append(txs[:i], txs[i+1:]...)
+ }
+ break out
+ }
+ }
+ }
+}
+
func (pool *TxPool) validatePool() {
pool.mu.Lock()
defer pool.mu.Unlock()
@@ -316,7 +337,7 @@ func (pool *TxPool) validatePool() {
glog.Infof("removed tx (%x) from pool: %v\n", hash[:4], err)
}
- delete(pool.txs, hash)
+ pool.removeTx(hash)
}
}
}