aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-07 08:21:45 +0800
committerobscuren <geffobscura@gmail.com>2015-01-07 08:21:45 +0800
commit60d9611c2365512c9a3e1576e875c5755ea0c74b (patch)
treecbb4cc43f44d1c79dc1aecd5e54f8bc47fa3a9ff
parentf0ec75123747424ab2606fe6ef650b13520fac22 (diff)
downloadgo-tangerine-60d9611c2365512c9a3e1576e875c5755ea0c74b.tar.gz
go-tangerine-60d9611c2365512c9a3e1576e875c5755ea0c74b.tar.zst
go-tangerine-60d9611c2365512c9a3e1576e875c5755ea0c74b.zip
Fixed tests where txs weren't properly removed
-rw-r--r--core/transaction_pool.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index ff6c21aa9..d3aec9050 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -56,11 +56,6 @@ func NewTxPool(eventMux *event.TypeMux) *TxPool {
}
func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
- hash := tx.Hash()
- if pool.txs[string(hash)] != nil {
- return fmt.Errorf("Known transaction (%x)", hash[0:4])
- }
-
if len(tx.To()) != 0 && len(tx.To()) != 20 {
return fmt.Errorf("Invalid recipient. len = %d", len(tx.To()))
}
@@ -97,6 +92,10 @@ func (self *TxPool) addTx(tx *types.Transaction) {
}
func (self *TxPool) Add(tx *types.Transaction) error {
+ if self.txs[string(tx.Hash())] != nil {
+ return fmt.Errorf("Known transaction (%x)", tx.Hash()[0:4])
+ }
+
err := self.ValidateTransaction(tx)
if err != nil {
return err
@@ -149,6 +148,7 @@ func (pool *TxPool) RemoveInvalid(query StateQuery) {
for _, tx := range pool.txs {
sender := query.GetAccount(tx.From())
err := pool.ValidateTransaction(tx)
+ fmt.Println(err, sender.Nonce, tx.Nonce())
if err != nil || sender.Nonce >= tx.Nonce() {
removedTxs = append(removedTxs, tx)
}