Skip to content

Commit

Permalink
miner: avoid unnecessary work (ethereum#15883)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee authored and karalabe committed Jan 15, 2018
1 parent 938cf45 commit 18a7d31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/gaspool.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func (gp *GasPool) SubGas(amount uint64) error {
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 {
return fmt.Sprintf("%d", *gp)
}
5 changes: 5 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
var coalescedLogs []*types.Log

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
tx := txs.Peek()
if tx == nil {
Expand Down

0 comments on commit 18a7d31

Please sign in to comment.