From 6f69cdd109b1dd692b8dfb15e7c53d2051fbc946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 13 Nov 2017 13:47:27 +0200 Subject: all: switch gas limits from big.Int to uint64 --- core/tx_list.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'core/tx_list.go') 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 -- cgit v1.2.3