Configtxlator script changes (#552)

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
This commit is contained in:
sapthasurendran 2021-12-09 17:07:38 +05:30 committed by GitHub
parent 06d67ecbfa
commit 9df7e9f86d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 14 deletions

View file

@ -34,19 +34,19 @@ function create_config_update() {
local modified=$2 local modified=$2
local output=$3 local output=$3
configtxlator proto_encode --input "${original}" --type common.Config > original_config.pb configtxlator proto_encode --input "${original}" --type common.Config --output original_config.pb
configtxlator proto_encode --input "${modified}" --type common.Config > modified_config.pb configtxlator proto_encode --input "${modified}" --type common.Config --output modified_config.pb
# returns non-zero if no updates were detected between current and new config # returns non-zero if no updates were detected between current and new config
configtxlator compute_update --channel_id "${CHANNEL_NAME}" --original original_config.pb --updated modified_config.pb > config_update.pb configtxlator compute_update --channel_id "${CHANNEL_NAME}" --original original_config.pb --updated modified_config.pb --output config_update.pb
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Anchor peer has already been set to ${ANCHOR_PEER_HOST}:${ANCHOR_PEER_PORT} - no update required." echo "Anchor peer has already been set to ${ANCHOR_PEER_HOST}:${ANCHOR_PEER_PORT} - no update required."
return 1 return 1
fi fi
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate > config_update.json configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate --output config_update.json
echo '{"payload":{"header":{"channel_header":{"channel_id":"'${CHANNEL_NAME}'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json echo '{"payload":{"header":{"channel_header":{"channel_id":"'${CHANNEL_NAME}'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope > ${output} configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope --output ${output}
return 0 return 0
} }

View file

@ -25,7 +25,8 @@ fetchChannelConfig() {
infoln "Decoding config block to JSON and isolating config to ${OUTPUT}" infoln "Decoding config block to JSON and isolating config to ${OUTPUT}"
set -x set -x
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config >"${OUTPUT}" configtxlator proto_decode --input config_block.pb --type common.Block --output config_block.json
jq .data.data[0].payload.data.config config_block.json >"${OUTPUT}"
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
} }
@ -40,12 +41,12 @@ createConfigUpdate() {
OUTPUT=$4 OUTPUT=$4
set -x set -x
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config >original_config.pb configtxlator proto_encode --input "${ORIGINAL}" --type common.Config --output original_config.pb
configtxlator proto_encode --input "${MODIFIED}" --type common.Config >modified_config.pb configtxlator proto_encode --input "${MODIFIED}" --type common.Config --output modified_config.pb
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb >config_update.pb configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb --output config_update.pb
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate >config_update.json configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate --output config_update.json
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . >config_update_in_envelope.json echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . >config_update_in_envelope.json
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope >"${OUTPUT}" configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope --output "${OUTPUT}"
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
} }