diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-23 08:57:04 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-23 08:57:04 +0800 |
commit | f5737b929a972102b16e4b206a52b1e36b508860 (patch) | |
tree | 753b75ac843c7a8a95dcb679a7f8e6df25764207 | |
parent | c66cf95b4019eeaf49db0c02cc7cb73c78098f5e (diff) | |
download | go-tangerine-f5737b929a972102b16e4b206a52b1e36b508860.tar.gz go-tangerine-f5737b929a972102b16e4b206a52b1e36b508860.tar.zst go-tangerine-f5737b929a972102b16e4b206a52b1e36b508860.zip |
Added a secondary processor
-rw-r--r-- | ethchain/transaction_pool.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go index 75a8aa5d1..1278cc4dc 100644 --- a/ethchain/transaction_pool.go +++ b/ethchain/transaction_pool.go @@ -34,6 +34,10 @@ type PublicSpeaker interface { Broadcast(msgType ethwire.MsgType, data []interface{}) } +type TxProcessor interface { + ProcessTransaction(tx *Transaction) +} + // The tx pool a thread safe transaction pool handler. In order to // guarantee a non blocking pool we use a queue channel which can be // independently read without needing access to the actual pool. If the @@ -54,7 +58,7 @@ type TxPool struct { BlockManager *BlockManager - Hook TxPoolHook + SecondaryProcessor TxProcessor } func NewTxPool() *TxPool { @@ -69,12 +73,14 @@ func NewTxPool() *TxPool { // Blocking function. Don't use directly. Use QueueTransaction instead func (pool *TxPool) addTransaction(tx *Transaction) { + log.Println("Adding tx to pool") pool.mutex.Lock() pool.pool.PushBack(tx) pool.mutex.Unlock() // Broadcast the transaction to the rest of the peers pool.Speaker.Broadcast(ethwire.MsgTxTy, []interface{}{tx.RlpData()}) + log.Println("broadcasting it") } // Process transaction validates the Tx and processes funds from the @@ -179,8 +185,8 @@ out: // doesn't matter since this is a goroutine pool.addTransaction(tx) - if pool.Hook != nil { - pool.Hook <- tx + if pool.SecondaryProcessor != nil { + pool.SecondaryProcessor.ProcessTransaction(tx) } } case <-pool.quit: |