How it works...
Like what we did in the Building the Fabric network recipe, the eyfn.sh script is a good resource to understand how things work.
We will also look into the command-line steps to see the internal building blocks to add an organization to a channel:
- Generate the org3 certificates:
$ cryptogen generate --config=./org3-crypto.yaml
- Generate the org3 configuration materials:
$ configtxgen -printOrg Org3MSP
- Generate and submit the transaction configuration for organization 3:
$ peer channel fetch config config_block.pb -o
orderer.example.com:7050 -c mychannel --tls --cafile
/opt/gopath/src/github.com/hyperledger/fabric/peer/
crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
$ configtxlator proto_encode --input config.json
--type common.Config
$ configtxlator proto_encode --input modified_config.json
--type common.Config
$ configtxlator compute_update --channel_id mychannel
--original original_config.pb --updated modified_config.pb
$ configtxlator proto_decode --input config_update.pb
--type common.ConfigUpdate
- Configure the transaction to add org3, which has been created:
$ peer channel signconfigtx -f org3_update_in_envelope.pb
- Submit the transaction from a different peer (peer0.org2), who also signs it:
$ peer channel update -f org3_update_in_envelope.pb -c mychannel -o
orderer.example.com:7050 --tls --cafile
/opt/gopath/src/github.com/hyperledger/fabric/peer/
crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
- Get the org3 peer to join the network:
$ peer channel fetch 0 mychannel.block -o orderer.example.com:7050
-c mychannel --tls --cafile /opt/gopath/src/github.com/
hyperledger/fabric/peer/crypto/ordererOrganizations/
example.com/orderers/orderer.example.com/
msp/tlscacerts/tlsca.example.com-cert.pem
$ peer channel join
-b mychannel.blockcd fabric-samples/first-network
- Install and update the chaincode:
$ peer chaincode install -n mycc -v 2.0 -l golang -p
github.com/chaincode/chaincode_example02/go/
$ peer chaincode upgrade -o orderer.example.com:7050
--tls true --cafile /opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
-C mychannel -n mycc -v 2.0 -c
'{"Args":["init","a","90","b","210"]}'
-P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'',
'\''Org3MSP.peer'\'')'
- Query peer0 org3:
$ peer chaincode query -C mychannel -n mycc
-c '{"Args":["query","a"]}'
- Invoke the transaction to move 10 from a to b again on a different peer:
$ peer chaincode invoke -o orderer.example.com:7050 --tls true
--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/
crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
-C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051
--tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/org1.example.com/peers/
peer0.org1.example.com/tls/ca.crt
--peerAddresses peer0.org2.example.com:7051
--tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/org2.example.com/peers/
peer0.org2.example.com/tls/ca.crt
--peerAddresses peer0.org3.example.com:7051
--tlsRootCertFiles/opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/org3.example.com/peers/
peer0.org3.example.com/tls/ca.crt
-c '{"Args":["invoke","a","b","10"]}'
This concludes how to add an organization to an existing network in a channel. We will look at how to use CouchDB to review transactions in the next recipe.
Following all the previous steps will create our first network, which consists of two organizations, two peers per organization, and single Solo ordering service. In this recipe, we showed you how to add a third organization to an application channel with its own peers to an already running first network, and then join it to the new channel.
When you view the log file, you will be able to see details in the following order:
- Generating Org3 config material
- Generating and submitting config tx to add Org3
- Creating config transaction to add Org3 to the network
- Installing jq
- Config transaction to add Org3 to the network
- Signing the config transaction
- Submitting the transaction from a different peer (peer0.org2), which also signs it
- Configure transaction to add Org3 to network submitted
- Having Org3 peers join the network
- Getting Org3 on to your first network
- Fetching the channel config block from orderer
- peer0.org3 joined the mychannel channel
- peer1.org3 joined the mychannel channel
- Installing chaincode 2.0 on peer0.org3
- Upgrading chaincode to have Org3 peers on the network
- Finishing adding Org3 to your first network
- Chaincode is installed on peer0.org1
- Chaincode is installed on peer0.org2
- Chaincode is upgraded on peer0.org1 on the mychannel channel
- Finished adding Org3 to your first network!
Updating modification policies or altering batch sizes or any other channel configuration can be updated using the same approach but for now we will focus solely on the integration of a new organization.