add limit on block size (#3760)

pull/3761/head
Rongjian Lan 4 years ago committed by GitHub
parent bd78e06cc2
commit 556e62da13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      node/worker/worker.go

@ -63,6 +63,7 @@ func (w *Worker) CommitSortedTransactions(
txs *types.TransactionsByPriceAndNonce,
coinbase common.Address,
) {
counter := 0
for {
// If we don't have enough gas for any further transactions then we're done
if w.current.gasPool.Gas() < params.TxGas {
@ -126,6 +127,11 @@ func (w *Worker) CommitSortedTransactions(
utils.Logger().Info().Str("hash", tx.Hash().Hex()).AnErr("err", err).Msg("Transaction failed, account skipped")
txs.Shift()
}
counter++
if counter >= 50 {
// Limit the number of txn per block as a temporary solution to spams.
break
}
}
}

Loading…
Cancel
Save