mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 13:06:40 +00:00
miner: re-use basefee and big.Int in loop (#34783)
This commit is contained in:
parent
da34eb59fd
commit
31bb680997
1 changed files with 6 additions and 2 deletions
|
|
@ -601,10 +601,14 @@ func (miner *Miner) fillTransactions(ctx context.Context, interrupt *atomic.Int3
|
||||||
|
|
||||||
// totalFees computes total consumed miner fees in Wei. Block transactions and receipts have to have the same order.
|
// totalFees computes total consumed miner fees in Wei. Block transactions and receipts have to have the same order.
|
||||||
func totalFees(block *types.Block, receipts []*types.Receipt) *big.Int {
|
func totalFees(block *types.Block, receipts []*types.Receipt) *big.Int {
|
||||||
|
baseFee := block.BaseFee()
|
||||||
feesWei := new(big.Int)
|
feesWei := new(big.Int)
|
||||||
|
var gasUsed, product big.Int
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
minerFee, _ := tx.EffectiveGasTip(block.BaseFee())
|
minerFee, _ := tx.EffectiveGasTip(baseFee)
|
||||||
feesWei.Add(feesWei, new(big.Int).Mul(new(big.Int).SetUint64(receipts[i].GasUsed), minerFee))
|
gasUsed.SetUint64(receipts[i].GasUsed)
|
||||||
|
product.Mul(&gasUsed, minerFee)
|
||||||
|
feesWei.Add(feesWei, &product)
|
||||||
}
|
}
|
||||||
return feesWei
|
return feesWei
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue