diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-02 19:26:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-02 19:26:55 +0800 |
commit | d336e24dcec2bb2cb89fff76302882aa82124dc8 (patch) | |
tree | 85337a9a58a2090b3a25cb140da6016deb3a5002 | |
parent | ae2c90cc2813509a3a2e848584a3a45b568ae064 (diff) | |
download | go-tangerine-d336e24dcec2bb2cb89fff76302882aa82124dc8.tar.gz go-tangerine-d336e24dcec2bb2cb89fff76302882aa82124dc8.tar.zst go-tangerine-d336e24dcec2bb2cb89fff76302882aa82124dc8.zip |
Removed the need of having a backend for the tx pool
-rw-r--r-- | core/chain_manager_test.go | 4 | ||||
-rw-r--r-- | core/transaction_pool.go | 23 | ||||
-rw-r--r-- | core/transaction_pool_test.go | 2 | ||||
-rw-r--r-- | eth/backend.go | 2 |
4 files changed, 14 insertions, 17 deletions
diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index 1e0ec3436..10ff7359b 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -78,7 +78,7 @@ func TestChainInsertions(t *testing.T) { var eventMux event.TypeMux chainMan := NewChainManager(&eventMux) - txPool := NewTxPool(chainMan, &eventMux) + txPool := NewTxPool(&eventMux) blockMan := NewBlockManager(txPool, chainMan, &eventMux) chainMan.SetProcessor(blockMan) @@ -122,7 +122,7 @@ func TestChainMultipleInsertions(t *testing.T) { } var eventMux event.TypeMux chainMan := NewChainManager(&eventMux) - txPool := NewTxPool(chainMan, &eventMux) + txPool := NewTxPool(&eventMux) blockMan := NewBlockManager(txPool, chainMan, &eventMux) chainMan.SetProcessor(blockMan) done := make(chan bool, max) diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 7f12a296d..3349c9441 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -43,22 +43,19 @@ type TxPool struct { subscribers []chan TxMsg - stateQuery StateQuery - eventMux *event.TypeMux + eventMux *event.TypeMux } -func NewTxPool(stateQuery StateQuery, eventMux *event.TypeMux) *TxPool { +func NewTxPool(eventMux *event.TypeMux) *TxPool { return &TxPool{ - pool: set.New(), - queueChan: make(chan *types.Transaction, txPoolQueueSize), - quit: make(chan bool), - stateQuery: stateQuery, - eventMux: eventMux, + pool: set.New(), + queueChan: make(chan *types.Transaction, txPoolQueueSize), + quit: make(chan bool), + eventMux: eventMux, } } func (pool *TxPool) addTransaction(tx *types.Transaction) { - pool.pool.Add(tx) // Broadcast the transaction to the rest of the peers @@ -75,6 +72,10 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { return fmt.Errorf("tx.v != (28 || 27) => %v", v) } + /* XXX this kind of validation needs to happen elsewhere in the gui when sending txs. + Other clients should do their own validation. Value transfer could throw error + but doesn't necessarily invalidate the tx. Gas can still be payed for and miner + can still be rewarded for their inclusion and processing. // Get the sender senderAddr := tx.From() if senderAddr == nil { @@ -82,10 +83,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { } sender := pool.stateQuery.GetAccount(senderAddr) - /* XXX this kind of validation needs to happen elsewhere in the gui when sending txs. - Other clients should do their own validation. Value transfer could be throw error - but doesn't necessarily invalidate the tx. Gas can still be payed for and miner - can still be rewarded for their inclusion and processing. totAmount := new(big.Int).Set(tx.Value()) // Make sure there's enough in the sender's account. Having insufficient // funds won't invalidate this transaction but simple ignores it. diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index 1214ad903..e77d7a1ae 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -25,7 +25,7 @@ func transaction() *types.Transaction { func setup() (*TxPool, *ecdsa.PrivateKey) { var m event.TypeMux key, _ := crypto.GenerateKey() - return NewTxPool(stateQuery{}, &m), key + return NewTxPool(&m), key } func TestTxAdding(t *testing.T) { diff --git a/eth/backend.go b/eth/backend.go index 383cda46f..78c2159c0 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -70,7 +70,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke } eth.chainManager = core.NewChainManager(eth.EventMux()) - eth.txPool = core.NewTxPool(eth.chainManager, eth.EventMux()) + eth.txPool = core.NewTxPool(eth.EventMux()) eth.blockManager = core.NewBlockManager(eth.txPool, eth.chainManager, eth.EventMux()) eth.chainManager.SetProcessor(eth.blockManager) eth.whisper = whisper.New() |