OSDN Git Service

add_soft_limit for max_tx per block (#555)
authorPaladz <yzhu101@uottawa.ca>
Thu, 29 Oct 2020 13:53:34 +0000 (21:53 +0800)
committerGitHub <noreply@github.com>
Thu, 29 Oct 2020 13:53:34 +0000 (21:53 +0800)
Co-authored-by: paladz <colt@ColtdeMBP.partners>
proposal/proposal.go

index 2832c9b..9381402 100644 (file)
@@ -22,6 +22,7 @@ import (
 const (
        logModule     = "mining"
        batchApplyNum = 64
+       softMaxTxNum  = 128
 
        timeoutOk = iota + 1
        timeoutWarn
@@ -119,7 +120,7 @@ func (b *blockBuilder) applyTransactions(txs []*types.Tx, timeoutStatus uint8) e
 
                b.gasLeft = gasLeft
                tempTxs = []*types.Tx{}
-               if b.getTimeoutStatus() >= timeoutStatus {
+               if b.getTimeoutStatus() >= timeoutStatus || len(b.block.Transactions) > softMaxTxNum {
                        break
                }
        }