From d336e24dcec2bb2cb89fff76302882aa82124dc8 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 2 Jan 2015 12:26:55 +0100 Subject: Removed the need of having a backend for the tx pool --- core/transaction_pool.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'core/transaction_pool.go') 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. -- cgit