Skip to content

Commit 4ab098f

Browse files
author
Jason Yellick
committed
[FAB-8327] Change eyfn.sh to use configtxlator cli
V1.1 introduces a new CLI for configtxlator which eliminates the need to run it as a REST service. Since this makes the example simpler, this CR changes those REST calls to be direct CLI invocations. Change-Id: I005068d1ca27946b9b6d4d1a2a1056268e366d61 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent 24f35c1 commit 4ab098f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

first-network/scripts/step1org3.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,37 @@ echo
3333
echo "========= Creating config transaction to add org3 to network =========== "
3434
echo
3535

36-
echo "Installing and starting configtxlater"
36+
echo "Installing jq"
3737
apt-get -y update && apt-get -y install jq
38-
configtxlator start >/dev/null 2>&1 &
39-
CONFIGTXLATOR_URL=http://127.0.0.1:7059
4038

4139
echo "Fetching the most recent configuration block for the channel"
4240
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c ${CHANNEL_NAME} --tls --cafile ${ORDERER_CA}
4341

4442
echo "Creating config transaction adding org3 to the network"
4543
# translate channel configuration block into JSON format
46-
curl -X POST --data-binary @config_block.pb "$CONFIGTXLATOR_URL/protolator/decode/common.Block" | jq . > config_block.json
44+
configtxlator proto_decode --input config_block.pb --type common.Block --output config_block.json
4745

4846
# strip away all of the encapsulating wrappers
4947
jq .data.data[0].payload.data.config config_block.json > config.json
5048

5149
# append new org to the configuration
52-
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./channel-artifacts/org3.json >& updated_config.json
50+
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./channel-artifacts/org3.json > modified_config.json
5351

5452
# translate json config files back to protobuf
55-
curl -X POST --data-binary @config.json "$CONFIGTXLATOR_URL/protolator/encode/common.Config" > config.pb
56-
curl -X POST --data-binary @updated_config.json "$CONFIGTXLATOR_URL/protolator/encode/common.Config" > updated_config.pb
53+
configtxlator proto_encode --input config.json --type common.Config --output config.pb
54+
configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
5755

5856
# get delta between old and new configs
59-
curl -X POST -F channel=${CHANNEL_NAME} -F "original=@config.pb" -F "updated=@updated_config.pb" "${CONFIGTXLATOR_URL}/configtxlator/compute/update-from-configs" > org3_update.pb
57+
configtxlator compute_update --channel_id ${CHANNEL_NAME} --original config.pb --updated modified_config.pb --output org3_update.pb
6058

6159
# translate protobuf delta to json
62-
curl -X POST --data-binary @org3_update.pb "$CONFIGTXLATOR_URL/protolator/decode/common.ConfigUpdate" | jq . > org3_update.json
60+
configtxlator proto_decode --input org3_update.pb --type common.ConfigUpdate --output org3_update.json
6361

6462
# wrap delta in an envelope message
6563
echo '{"payload":{"header":{"channel_header":{"channel_id":"'${CHANNEL_NAME}'", "type":2}},"data":{"config_update":'$(cat org3_update.json)'}}}' | jq . > org3_update_in_envelope.json
6664

6765
# translate json back to protobuf
68-
curl -X POST --data-binary @org3_update_in_envelope.json "$CONFIGTXLATOR_URL/protolator/encode/common.Envelope" > org3_update_in_envelope.pb
66+
configtxlator proto_encode --input org3_update_in_envelope.json --type common.Envelope --output org3_update_in_envelope.pb
6967

7068
echo
7169
echo "========= Config transaction to add org3 to network created ===== "

0 commit comments

Comments
 (0)