|
33 | 33 | echo "========= Creating config transaction to add org3 to network =========== "
|
34 | 34 | echo
|
35 | 35 |
|
36 |
| -echo "Installing and starting configtxlater" |
| 36 | +echo "Installing jq" |
37 | 37 | 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 |
40 | 38 |
|
41 | 39 | echo "Fetching the most recent configuration block for the channel"
|
42 | 40 | peer channel fetch config config_block.pb -o orderer.example.com:7050 -c ${CHANNEL_NAME} --tls --cafile ${ORDERER_CA}
|
43 | 41 |
|
44 | 42 | echo "Creating config transaction adding org3 to the network"
|
45 | 43 | # 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 |
47 | 45 |
|
48 | 46 | # strip away all of the encapsulating wrappers
|
49 | 47 | jq .data.data[0].payload.data.config config_block.json > config.json
|
50 | 48 |
|
51 | 49 | # 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 |
53 | 51 |
|
54 | 52 | # 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 |
57 | 55 |
|
58 | 56 | # 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 |
60 | 58 |
|
61 | 59 | # 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 |
63 | 61 |
|
64 | 62 | # wrap delta in an envelope message
|
65 | 63 | echo '{"payload":{"header":{"channel_header":{"channel_id":"'${CHANNEL_NAME}'", "type":2}},"data":{"config_update":'$(cat org3_update.json)'}}}' | jq . > org3_update_in_envelope.json
|
66 | 64 |
|
67 | 65 | # 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 |
69 | 67 |
|
70 | 68 | echo
|
71 | 69 | echo "========= Config transaction to add org3 to network created ===== "
|
|
0 commit comments