diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-30 08:22:19 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-30 08:22:19 +0800 |
commit | 7625b07dd9a2a7b5c5a504c1276eea04596ac871 (patch) | |
tree | ce2a757cd4e0591fc15815b2dfae528ae517d36e /core/transaction_pool.go | |
parent | 72e2613a9fe3205fa5a67b72b832e03b2357ee88 (diff) | |
parent | 8f504063f465e0ca10c6bb53ee914d10a3d45c86 (diff) | |
download | go-tangerine-0.9.34.tar go-tangerine-0.9.34.tar.gz go-tangerine-0.9.34.tar.bz2 go-tangerine-0.9.34.tar.lz go-tangerine-0.9.34.tar.xz go-tangerine-0.9.34.tar.zst go-tangerine-0.9.34.zip |
Merge branch 'release/0.9.34'v0.9.34
Diffstat (limited to 'core/transaction_pool.go')
-rw-r--r-- | core/transaction_pool.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 34a1733d7..bf28647c3 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -162,27 +162,25 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error { // Check the transaction doesn't exceed the current // block limit gas. - if pool.gasLimit().Cmp(tx.GasLimit) < 0 { + if pool.gasLimit().Cmp(tx.Gas()) < 0 { return ErrGasLimit } // Transactions can't be negative. This may never happen // using RLP decoded transactions but may occur if you create // a transaction using the RPC for example. - if tx.Amount.Cmp(common.Big0) < 0 { + if tx.Value().Cmp(common.Big0) < 0 { return ErrNegativeValue } // Transactor should have enough funds to cover the costs // cost == V + GP * GL - total := new(big.Int).Mul(tx.Price, tx.GasLimit) - total.Add(total, tx.Value()) - if pool.currentState().GetBalance(from).Cmp(total) < 0 { + if pool.currentState().GetBalance(from).Cmp(tx.Cost()) < 0 { return ErrInsufficientFunds } // Should supply enough intrinsic gas - if tx.GasLimit.Cmp(IntrinsicGas(tx)) < 0 { + if tx.Gas().Cmp(IntrinsicGas(tx.Data())) < 0 { return ErrIntrinsicGas } @@ -238,7 +236,7 @@ func (pool *TxPool) addTx(hash common.Hash, addr common.Address, tx *types.Trans // Increment the nonce on the pending state. This can only happen if // the nonce is +1 to the previous one. - pool.pendingState.SetNonce(addr, tx.AccountNonce+1) + pool.pendingState.SetNonce(addr, tx.Nonce()+1) // Notify the subscribers. This event is posted in a goroutine // because it's possible that somewhere during the post "Remove transaction" // gets called which will then wait for the global tx pool lock and deadlock. @@ -341,7 +339,7 @@ func (pool *TxPool) checkQueue() { trueNonce := pool.currentState().GetNonce(address) addq := addq[:0] for hash, tx := range txs { - if tx.AccountNonce < trueNonce { + if tx.Nonce() < trueNonce { // Drop queued transactions whose nonce is lower than // the account nonce because they have been processed. delete(txs, hash) @@ -362,8 +360,7 @@ func (pool *TxPool) checkQueue() { delete(pool.queue[address], e.hash) continue } - - if e.AccountNonce > guessedNonce { + if e.Nonce() > guessedNonce { break } delete(txs, e.hash) @@ -418,4 +415,4 @@ type txQueueEntry struct { func (q txQueue) Len() int { return len(q) } func (q txQueue) Swap(i, j int) { q[i], q[j] = q[j], q[i] } -func (q txQueue) Less(i, j int) bool { return q[i].AccountNonce < q[j].AccountNonce } +func (q txQueue) Less(i, j int) bool { return q[i].Nonce() < q[j].Nonce() } |