github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/examples/configtxupdate/bootstrap_batchsize/script.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright IBM Corp. All Rights Reserved.
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  CDIR=$(dirname $(basename "$0"))
     9  
    10  : ${OUTDIR:="example_output"}
    11  mkdir -p ${OUTDIR} || die "could not create output dir ${OUTDIR}"
    12  
    13  GENESIS_BLOCK_PB="${OUTDIR}/genesis_block.pb"
    14  GENESIS_BLOCK_JSON="${OUTDIR}/genesis_block.json"
    15  UPDATED_GENESIS_BLOCK_JSON="${OUTDIR}/updated_genesis_block.json"
    16  UPDATED_GENESIS_BLOCK_PB="${OUTDIR}/updated_genesis_block.pb"
    17  
    18  . ${CDIR}/../common_scripts/common.sh
    19  
    20  findConfigtxgen || die "no configtxgen present"
    21  
    22  bigMsg "Creating bootstrap block"
    23  
    24  echo -e "Executing:\n\tconfigtxgen -outputBlock '${GENESIS_BLOCK_PB}' -profile SampleSingleMSPSolo"
    25  $CONFIGTXGEN -outputBlock "${GENESIS_BLOCK_PB}" -profile SampleSingleMSPSolo 2>/dev/null || die "Error generating genesis block"
    26  
    27  pauseIfInteractive
    28  
    29  bigMsg "Decoding genesis block"
    30  decode common.Block "${GENESIS_BLOCK_PB}" "${GENESIS_BLOCK_JSON}"
    31  
    32  bigMsg "Updating the genesis config"
    33  ORIGINAL_BATCHSIZE=$(jq ".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count" genesis_block.json)
    34  NEW_BATCHSIZE=$(( ${ORIGINAL_BATCHSIZE} + 1 ))
    35  echo "Updating batch size from ${ORIGINAL_BATCHSIZE} to ${NEW_BATCHSIZE}."
    36  echo -e "Executing\n\tjq '.data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count = ${NEW_BATCHSIZE}' '${GENESIS_BLOCK_JSON}' > '${UPDATED_GENESIS_BLOCK_JSON}'"
    37  jq ".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count = ${NEW_BATCHSIZE}" "${GENESIS_BLOCK_JSON}" > "${UPDATED_GENESIS_BLOCK_JSON}"
    38  
    39  pauseIfInteractive
    40  
    41  bigMsg "Re-encoding the updated genesis block"
    42  
    43  encode common.Block "${UPDATED_GENESIS_BLOCK_JSON}" "${UPDATED_GENESIS_BLOCK_PB}"
    44  
    45  bigMsg "Bootstrapping edit complete"