diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/filter.go | 6 | ||||
-rw-r--r-- | core/transaction_pool.go | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/core/filter.go b/core/filter.go index c10fb7eeb..2ca57da65 100644 --- a/core/filter.go +++ b/core/filter.go @@ -22,9 +22,9 @@ type Filter struct { max int topics [][]common.Hash - BlockCallback func(*types.Block, state.Logs) - PendingCallback func(*types.Transaction) - LogsCallback func(state.Logs) + BlockCallback func(*types.Block, state.Logs) + TransactionCallback func(*types.Transaction) + LogsCallback func(state.Logs) } // Create a new filter which uses a bloom filter on blocks to figure out whether a particular block diff --git a/core/transaction_pool.go b/core/transaction_pool.go index bac6b7f0b..6898a4bda 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -204,6 +204,27 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) { } } +// GetTransaction allows you to check the pending and queued transaction in the +// transaction pool. +// It has two stategies, first check the pool (map) then check the queue +func (tp *TxPool) GetTransaction(hash common.Hash) *types.Transaction { + // check the txs first + if tx, ok := tp.txs[hash]; ok { + return tx + } + + // check queue + for _, txs := range tp.queue { + for _, tx := range txs { + if tx.Hash() == hash { + return tx + } + } + } + + return nil +} + func (self *TxPool) GetTransactions() (txs types.Transactions) { self.mu.RLock() defer self.mu.RUnlock() |