[chain] fix invalid block size limit
@@ -38,8 +38,7 @@ var (
func Init(maxBlkBodySize uint32, coinbaseAccountStr string, isBp bool, maxAnchorCount int, verifierCount int) error {
var err error
- setMaxBlockBodySize(maxBlkBodySize)
- setMaxBlockSize(MaxBlockBodySize() + types.DefaultMaxHdrSize)
+ setBlockSizeLimit(maxBlkBodySize)
if isBp {
if len(coinbaseAccountStr) != 0 {
@@ -69,7 +68,7 @@ func IsPublic() bool {
func initChainEnv(genesis *types.Genesis) {
pubNet = genesis.ID.PublicNet
if pubNet {
- setMaxBlockBodySize(pubNetMaxBlockBodySize)
+ setBlockSizeLimit(pubNetMaxBlockBodySize)
}
if err := setConsensusName(genesis.ConsensusType()); err != nil {
logger.Panic().Err(err).Msg("invalid consensus type in genesis block")
@@ -90,8 +89,9 @@ func setMaxBlockBodySize(size uint32) {
maxBlockBodySize = size
}
-func setMaxBlockSize(size uint32) {
- maxBlockSize = size
+func setBlockSizeLimit(maxBlockBodySize uint32) {
+ setMaxBlockBodySize(maxBlockBodySize)
+ maxBlockSize = MaxBlockBodySize() + types.DefaultMaxHdrSize
}
func setConsensusName(val string) error {
