aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/transaction_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-27 23:52:58 +0800
committerobscuren <geffobscura@gmail.com>2014-10-27 23:52:58 +0800
commit69e745c537e442d4086986b02c01741d2a314cf1 (patch)
treefde28b31fd7ae1eaf8017f300b9d60fece782e5f /ethchain/transaction_pool.go
parent003280888d54ddcb7d776f549633d280edee1c8c (diff)
downloadgo-tangerine-69e745c537e442d4086986b02c01741d2a314cf1.tar.gz
go-tangerine-69e745c537e442d4086986b02c01741d2a314cf1.tar.zst
go-tangerine-69e745c537e442d4086986b02c01741d2a314cf1.zip
Return erroneous txs (so we can remove them from the pool)
Diffstat (limited to 'ethchain/transaction_pool.go')
-rw-r--r--ethchain/transaction_pool.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go
index 063688aa8..7f8a5de42 100644
--- a/ethchain/transaction_pool.go
+++ b/ethchain/transaction_pool.go
@@ -35,6 +35,14 @@ type TxMsg struct {
Type TxMsgTy
}
+func EachTx(pool *list.List, it func(*Transaction, *list.Element) bool) {
+ for e := pool.Front(); e != nil; e = e.Next() {
+ if it(e.Value.(*Transaction), e) {
+ break
+ }
+ }
+}
+
func FindTx(pool *list.List, finder func(*Transaction, *list.Element) bool) *Transaction {
for e := pool.Front(); e != nil; e = e.Next() {
if tx, ok := e.Value.(*Transaction); ok {
@@ -191,6 +199,9 @@ func (pool *TxPool) CurrentTransactions() []*Transaction {
}
func (pool *TxPool) RemoveInvalid(state *ethstate.State) {
+ pool.mutex.Lock()
+ defer pool.mutex.Unlock()
+
for e := pool.pool.Front(); e != nil; e = e.Next() {
tx := e.Value.(*Transaction)
sender := state.GetAccount(tx.Sender())
@@ -201,6 +212,21 @@ func (pool *TxPool) RemoveInvalid(state *ethstate.State) {
}
}
+func (self *TxPool) RemoveSet(txs Transactions) {
+ self.mutex.Lock()
+ defer self.mutex.Unlock()
+
+ for _, tx := range txs {
+ EachTx(self.pool, func(t *Transaction, element *list.Element) bool {
+ if t == tx {
+ self.pool.Remove(element)
+ return true // To stop the loop
+ }
+ return false
+ })
+ }
+}
+
func (pool *TxPool) Flush() []*Transaction {
txList := pool.CurrentTransactions()