From 18a7d313386194be39e733ac3043988690f42464 Mon Sep 17 00:00:00 2001
From: Jim McDonald <Jim@mcdee.net>
Date: Mon, 15 Jan 2018 10:57:06 +0000
Subject: miner: avoid unnecessary work (#15883)

---
 miner/worker.go | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'miner')

diff --git a/miner/worker.go b/miner/worker.go
index 638f759bf..1520277e1 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -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 {
-- 
cgit v1.2.3