diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-08 17:56:55 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-08 17:56:55 +0800 |
commit | 637b2415d969a97b3d119be2aceb9411458d00d9 (patch) | |
tree | 3d61d0853f51bdca06881033b45ec22a9ddbe630 /core | |
parent | 69aac4d5316ca8ec3429de534349a8dbdb0b59a5 (diff) | |
parent | 60b5a94428abf57dc921347684508db44f0f1a04 (diff) | |
download | dexon-637b2415d969a97b3d119be2aceb9411458d00d9.tar dexon-637b2415d969a97b3d119be2aceb9411458d00d9.tar.gz dexon-637b2415d969a97b3d119be2aceb9411458d00d9.tar.bz2 dexon-637b2415d969a97b3d119be2aceb9411458d00d9.tar.lz dexon-637b2415d969a97b3d119be2aceb9411458d00d9.tar.xz dexon-637b2415d969a97b3d119be2aceb9411458d00d9.tar.zst dexon-637b2415d969a97b3d119be2aceb9411458d00d9.zip |
Merge pull request #864 from obscuren/filter_changes
xeth, core, event/filter, rpc: new block and transaction filters
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() |