aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/transaction_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-23 08:57:04 +0800
committerobscuren <geffobscura@gmail.com>2014-02-23 08:57:04 +0800
commitf5737b929a972102b16e4b206a52b1e36b508860 (patch)
tree753b75ac843c7a8a95dcb679a7f8e6df25764207 /ethchain/transaction_pool.go
parentc66cf95b4019eeaf49db0c02cc7cb73c78098f5e (diff)
downloaddexon-f5737b929a972102b16e4b206a52b1e36b508860.tar.gz
dexon-f5737b929a972102b16e4b206a52b1e36b508860.tar.zst
dexon-f5737b929a972102b16e4b206a52b1e36b508860.zip
Added a secondary processor
Diffstat (limited to 'ethchain/transaction_pool.go')
-rw-r--r--ethchain/transaction_pool.go12
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: