mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-22 03:30:35 +00:00
miner: avoid unnecessary work (#15883)
This commit is contained in:
parent
938cf4528a
commit
18a7d31338
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user