Commit 18a7d313 authored by Jim McDonald's avatar Jim McDonald Committed by Péter Szilágyi

miner: avoid unnecessary work (#15883)

parent 938cf452
...@@ -44,6 +44,11 @@ func (gp *GasPool) SubGas(amount uint64) error { ...@@ -44,6 +44,11 @@ func (gp *GasPool) SubGas(amount uint64) error {
return nil return nil
} }
// Gas returns the amount of gas remaining in the pool.
func (gp *GasPool) Gas() uint64 {
return uint64(*gp)
}
func (gp *GasPool) String() string { func (gp *GasPool) String() string {
return fmt.Sprintf("%d", *gp) return fmt.Sprintf("%d", *gp)
} }
...@@ -512,6 +512,11 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB ...@@ -512,6 +512,11 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
var coalescedLogs []*types.Log var coalescedLogs []*types.Log
for { for {
// If we don't have enough gas for any further transactions then we're done
if gp.Gas() < params.TxGas {
log.Trace("Not enough gas for further transactions", "gp", gp)
break
}
// Retrieve the next transaction and abort if all done // Retrieve the next transaction and abort if all done
tx := txs.Peek() tx := txs.Peek()
if tx == nil { if tx == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment