diff options
author | Felix Lange <fjl@twurst.com> | 2015-06-27 09:08:50 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-30 00:51:48 +0800 |
commit | 76821d167acd7da15e13b23beeceb6779138ffe5 (patch) | |
tree | 73af5b18546dcb4db62e9e7f24d8bb103cdbfcef /eth/gasprice.go | |
parent | fccc7d71eb1e8e655f9bcd9c6d7856b70bbeda36 (diff) | |
download | go-tangerine-76821d167acd7da15e13b23beeceb6779138ffe5.tar.gz go-tangerine-76821d167acd7da15e13b23beeceb6779138ffe5.tar.zst go-tangerine-76821d167acd7da15e13b23beeceb6779138ffe5.zip |
core, eth, rpc: avoid unnecessary block header copying
Diffstat (limited to 'eth/gasprice.go')
-rw-r--r-- | eth/gasprice.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/eth/gasprice.go b/eth/gasprice.go index cd5293691..44202d709 100644 --- a/eth/gasprice.go +++ b/eth/gasprice.go @@ -133,20 +133,20 @@ func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int { gasUsed = recepits[len(recepits)-1].CumulativeGasUsed } - if new(big.Int).Mul(gasUsed, big.NewInt(100)).Cmp(new(big.Int).Mul(block.Header().GasLimit, + if new(big.Int).Mul(gasUsed, big.NewInt(100)).Cmp(new(big.Int).Mul(block.GasLimit(), big.NewInt(int64(self.eth.GpoFullBlockRatio)))) < 0 { // block is not full, could have posted a tx with MinGasPrice return self.eth.GpoMinGasPrice } - if len(block.Transactions()) < 1 { + txs := block.Transactions() + if len(txs) == 0 { return self.eth.GpoMinGasPrice } - // block is full, find smallest gasPrice - minPrice := block.Transactions()[0].GasPrice() - for i := 1; i < len(block.Transactions()); i++ { - price := block.Transactions()[i].GasPrice() + minPrice := txs[0].GasPrice() + for i := 1; i < len(txs); i++ { + price := txs[i].GasPrice() if price.Cmp(minPrice) < 0 { minPrice = price } |