github.com/franono/tendermint@v0.32.2-0.20200527150959-749313264ce9/state/tx_filter.go (about)

     1  package state
     2  
     3  import (
     4  	mempl "github.com/franono/tendermint/mempool"
     5  	"github.com/franono/tendermint/types"
     6  )
     7  
     8  // TxPreCheck returns a function to filter transactions before processing.
     9  // The function limits the size of a transaction to the block's maximum data size.
    10  func TxPreCheck(state State) mempl.PreCheckFunc {
    11  	maxDataBytes := types.MaxDataBytesUnknownEvidence(
    12  		state.ConsensusParams.Block.MaxBytes,
    13  		state.Validators.Size(),
    14  		state.ConsensusParams.Evidence.MaxNum,
    15  	)
    16  	return mempl.PreCheckAminoMaxBytes(maxDataBytes)
    17  }
    18  
    19  // TxPostCheck returns a function to filter transactions after processing.
    20  // The function limits the gas wanted by a transaction to the block's maximum total gas.
    21  func TxPostCheck(state State) mempl.PostCheckFunc {
    22  	return mempl.PostCheckMaxGas(state.ConsensusParams.Block.MaxGas)
    23  }