简体   繁体   中英

Where does the chaincode exist in a hyperledger fabric?

Being new to Blockchain and Hyperledger Fabric I am trying to find answers to the below questions,

I am planning to use the IBM Bluemix starter plan and install a chaincode to a sample fabric network using a BNA developed in Hyperledger composer.

  1. In a multi-org, multi-peer setup (real world scenario) where does the chaincode exist (or gets installed) in the Hyperledger Fabric network - is it confined to a specific peer or all the peers in a channel?

  2. If the chaincode is residing in a specific peer then what happens to the network in case the peer is down (due to connectivity disruption or other unforeseen calamities) - will the whole channel be unable to operate without a chaincode?

  3. How can multiple chaincodes in various peers access the same set of data in hyperledger fabric?

    • I saw this content in http://hyperledger-fabric.readthedocs.io : “State created by a chaincode is scoped exclusively to that chaincode and can't be accessed directly by another chaincode. Given the appropriate permission, a chaincode may invoke another chaincode, either in the same channel or in different channels, to access its state. Note that, if the called chaincode is on a different channel from the calling chaincode, only read query is allowed”. But i am not sure how to grant the "appropriate permission".

In a multi-org, multi-peer setup (real world scenario) where does the chaincode exist (or gets installed) in the Hyperledger Fabric network - is it confined to a specific peer or all the peers in a channel?

Chaincodes are installed on every peer which has to endorse a given transaction. Endorsement involves execution of the chaincode with some given arguments, finding out the result and signing it (with MSP of the org that the peer is a part of). Chaincodes are installed on a per peer basis and can be instantiated on one or more channels. If peer is belonging to a channel but is not endorsing any transactions, then it doesn't need not the chaincode. It can just choose to store the ledger of the given channel (act as a committing peer).

If the chaincode is residing in a specific peer then what happens to the network in case the peer is down (due to connectivity disruption or other unforeseen calamities) - will the whole channel be unable to operate without a chaincode?

If there is more than one endorsing peer per organization's MSP, you can sign and continue transactions smoothly. Setting up more than one peer per ORG MSP can help in crash fault tolerance as you have explained. Secondly, if there is only one peer per ORG MSP and your endorsement policy is such that you absolutely require the signature of that MSP for your transaction to go through only then the channel's transaction for that given chaincode will fail. Other chaincodes on the same channel, that does not require this signature will still continue to function fine.

How can multiple chaincodes in various peers access the same set of data in hyperledger fabric?

By permission, it means that if the invoker organization's MSP has rights to access the channel. So if you are trying to invoke Channel2's data from Channel1 then you (the invoking client) has to be a part of that channel either as a reader/writer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM