Reputation: 77
I have a question regarding Installing smart contact on peers. There is a Hyperledger fabric network having one organization Org1 and four peers.
peer0.org1.example.com
peer2.org1.example.com
peer3.org1.example.com
peer4.org1.example.com
While creating the network do we have to install smart contracts on each peer or only on one peer. If it is installed on one peer so in that case do other peer gets the smart contract in the background automatically. In the below code, I can see that contract is only installed on one peer.
echo "Installing smart contract on peer0.org1.example.com"
docker exec \
-e CORE_PEER_LOCALMSPID=Org1MSP \
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 \
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH} \
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE} \
cli \
peer chaincode install \
-n autokab \
-v 1.0 \
-p "$CC_SRC_PATH" \
-l "$CC_RUNTIME_LANGUAGE"
Upvotes: 0
Views: 143
Reputation: 474
If you want to invoke or query data from a ledger that is hosted by a peer, you have to install smart contracts.
Your peer can validate and commit transactions into the ledger due to underlying system but for invoke or query data from ledger, you need to install smart contracts.
Upvotes: 0
Reputation: 1695
On a high level -
Chaincode should only be installed on endorsing peer nodes of the owning members of the chaincode to protect the confidentiality of the chaincode logic from other members on the network. Those members without the chaincode, can’t be the endorsers of the chaincode’s transactions; that is, they can’t execute the chaincode. However, they can still validate and commit the transactions to the ledger.
In your example only peer0.org1.example.com will become endorsing peer and has the below capability -
Every peer with a smart contract can be an endorsing peer if it has a smart contract installed. However, to actually be an endorsing peer, the smart contract on the peer must be used by a client application to generate a digitally signed transaction response.
You can see the Transaction Flow example
And for more documentation
Upvotes: 0