Skip to content

Commit

Permalink
change peeraddress
Browse files Browse the repository at this point in the history
Signed-off-by: sapthasurendran <[email protected]>
  • Loading branch information
sapthasurendran committed Nov 30, 2021
1 parent 3f17f50 commit 7f58719
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 14 additions & 14 deletions fabric-network/docker-based-syschannel/scripts/addNewOrderer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fetchChannelConfig() {

infoln "Decoding config block to JSON and isolating config to ${OUTPUT}"
set -x
configtxlator proto_decode --input config_block.pb --type common.Block --output ${OUTPUT}.json
configtxlator proto_decode --input config_block.pb --type common.Block --output ${OUTPUT}
{ set +x; } 2>/dev/null


Expand All @@ -83,16 +83,15 @@ createConfigUpdateTLS() {
OUTPUT=$4

TLS_FILE=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer6.example.com/tls/server.crt
echo ${TLS_FILE}
echo 'path' ${PWD}


set -x
# filter requird data
jq .data.data[0].payload.data.config config_block.json > "${ORIGINAL}"

# edit orderer address
echo "{\"client_tls_cert\":\"$(cat $TLS_FILE | base64)\",\"host\":\"orderer6.example.com\",\"port\":7056,\"server_tls_cert\":\"$(cat $TLS_FILE | base64)\"}" > $PWD/org6consenter.json
jq ".channel_group.groups.Orderer.values.ConsensusType.value.metadata.consenters += [$(cat org6consenter.json)]" config.json > modified_config.json
jq ".channel_group.groups.Orderer.values.ConsensusType.value.metadata.consenters += [$(cat org6consenter.json)]" ${ORIGINAL} > ${MODIFIED}

configtxlator proto_encode --input "${ORIGINAL}" --type common.Config --output config.pb
configtxlator proto_encode --input "${MODIFIED}" --type common.Config --output modified_config.pb
Expand Down Expand Up @@ -151,11 +150,11 @@ signConfigtxAsPeerOrg() {
# Submit the config update transaction
submitConfigUpdateTransaction(){

infoln "Submitting config update transaction"
ORG=$1
CHANNEL=$2
CONFIGTXFILE=$3
setOrderer $ORG
infoln "Submitting config update transaction"
ORG=$1
CHANNEL=$2
CONFIGTXFILE=$3
setOrderer $ORG
set -x

peer channel update -f $CONFIGTXFILE -c $CHANNEL -o localhost:7050 --tls --cafile $ORDERER_CA
Expand Down Expand Up @@ -183,7 +182,7 @@ fetchConfigBlock(){
generateOrdererCrypto

# fetch latest config block from sysytem channel
fetchChannelConfig 1 'system-channel ' 'config_block'
fetchChannelConfig 1 'system-channel ' 'config_block.json'
# create config update for system channel
createConfigUpdateTLS 'system-channel' 'config.json' 'modified_config.json' 'config_update_in_envelope.pb'
# sign the config update
Expand All @@ -204,22 +203,23 @@ fetchChannelConfig 1 'system-channel ' 'config_block'
# update endpoint info in sysytem channel
createConfigUpdateEndpoint 'system-channel' 'config.json' 'modified_config.json' 'config_update_in_envelope.pb'
# sign the update
signConfigtxAsPeerOrg 1 'config_update_in_envelope.pb'
# signConfigtxAsPeerOrg 1 'config_update_in_envelope.pb'
# submit update in system channel
submitConfigUpdateTransaction 1 'system-channel' 'config_update_in_envelope.pb'

# Application channel updates

fetchChannelConfig 1 'mychannel ' 'config_block'
createConfigUpdateTLS 'mychannel' 'config.json' 'modified_config.json' 'config_update_in_envelope.pb'
signConfigtxAsPeerOrg 1 'config_update_in_envelope.pb'
# signConfigtxAsPeerOrg 1 'config_update_in_envelope.pb'
submitConfigUpdateTransaction 1 'mychannel' 'config_update_in_envelope.pb'
fetchChannelConfig 1 'mychannel ' 'config_block'


createConfigUpdateEndpoint
createConfigUpdateEndpoint 'mychannel' 'config.json' 'modified_config.json' 'config_update_in_envelope.pb'
signConfigtxAsPeerOrg 1 'config_update_in_envelope.pb'
# signConfigtxAsPeerOrg 1 'config_update_in_envelope.pb'
submitConfigUpdateTransaction 1 'mychannel' 'config_update_in_envelope.pb'


#verify latest block
fetchChannelConfig 1 'mychannel ' 'latest.json'
6 changes: 4 additions & 2 deletions fabric-network/docker-based-syschannel/scripts/envVar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,18 @@ setOrderer(){
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/ordererOrganizations/example.com/users/[email protected]/msp
export CORE_PEER_TLS_CERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
export CORE_PEER_TLS_KEY_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051
export CORE_PEER_ADDRESS=orderer1.example.com:7050
elif [ $USING_ORG -eq 2 ]; then
export CORE_PEER_LOCALMSPID="OrdererMSP"
export CORE_PEER_TLS_ROOTCERT_FILE=$ORDERER2_CA
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/ordererOrganizations/example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=orderer2.example.com:7051

elif [ $USING_ORG -eq 3 ]; then
export CORE_PEER_LOCALMSPID="OrdererMSP"
export CORE_PEER_TLS_ROOTCERT_FILE=$PEER1_ORG3_CA
export CORE_PEER_TLS_ROOTCERT_FILE=$ORDERER2_CA
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/ordererOrganizations/example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=orderer3.example.com:7052
else
errorln "ORG Unknown"
fi
Expand Down

0 comments on commit 7f58719

Please sign in to comment.