diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-11-13 19:47:27 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-01-03 20:45:35 +0800 |
commit | 6f69cdd109b1dd692b8dfb15e7c53d2051fbc946 (patch) | |
tree | c92974f8b82209073ad1ee3faec6e149f834bf69 /core/tx_list.go | |
parent | b8caba97099ee5eed33c3b80dd4ea540722e7d8f (diff) | |
download | dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.gz dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.bz2 dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.lz dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.xz dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.zst dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.zip |
all: switch gas limits from big.Int to uint64
Diffstat (limited to 'core/tx_list.go')
-rw-r--r-- | core/tx_list.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/core/tx_list.go b/core/tx_list.go index 838433b89..55fc42617 100644 --- a/core/tx_list.go +++ b/core/tx_list.go @@ -224,7 +224,7 @@ type txList struct { txs *txSortedMap // Heap indexed sorted hash map of the transactions costcap *big.Int // Price of the highest costing transaction (reset only if exceeds balance) - gascap *big.Int // Gas limit of the highest spending transaction (reset only if exceeds block limit) + gascap uint64 // Gas limit of the highest spending transaction (reset only if exceeds block limit) } // newTxList create a new transaction list for maintaining nonce-indexable fast, @@ -234,7 +234,6 @@ func newTxList(strict bool) *txList { strict: strict, txs: newTxSortedMap(), costcap: new(big.Int), - gascap: new(big.Int), } } @@ -266,7 +265,7 @@ func (l *txList) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Tran if cost := tx.Cost(); l.costcap.Cmp(cost) < 0 { l.costcap = cost } - if gas := tx.Gas(); l.gascap.Cmp(gas) < 0 { + if gas := tx.Gas(); l.gascap < gas { l.gascap = gas } return true, old @@ -288,16 +287,16 @@ func (l *txList) Forward(threshold uint64) types.Transactions { // a point in calculating all the costs or if the balance covers all. If the threshold // is lower than the costgas cap, the caps will be reset to a new high after removing // the newly invalidated transactions. -func (l *txList) Filter(costLimit, gasLimit *big.Int) (types.Transactions, types.Transactions) { +func (l *txList) Filter(costLimit *big.Int, gasLimit uint64) (types.Transactions, types.Transactions) { // If all transactions are below the threshold, short circuit - if l.costcap.Cmp(costLimit) <= 0 && l.gascap.Cmp(gasLimit) <= 0 { + if l.costcap.Cmp(costLimit) <= 0 && l.gascap <= gasLimit { return nil, nil } l.costcap = new(big.Int).Set(costLimit) // Lower the caps to the thresholds - l.gascap = new(big.Int).Set(gasLimit) + l.gascap = gasLimit // Filter out all the transactions above the account's funds - removed := l.txs.Filter(func(tx *types.Transaction) bool { return tx.Cost().Cmp(costLimit) > 0 || tx.Gas().Cmp(gasLimit) > 0 }) + removed := l.txs.Filter(func(tx *types.Transaction) bool { return tx.Cost().Cmp(costLimit) > 0 || tx.Gas() > gasLimit }) // If the list was strict, filter anything above the lowest nonce var invalids types.Transactions |