DeployChaincode is a helper that will install chaincode to all peers that are connected to the specified channel, approve the chaincode on one of the peers of each organization in the network, commit the chaincode definition on the channel using one of the peers, and wait for the chaincode commit to
(n *Network, channel string, orderer *Orderer, chaincode Chaincode, peers ...*Peer)
| 61 | // complete on all of the peers. It uses the _lifecycle implementation. |
| 62 | // NOTE V2_0 capabilities must be enabled for this functionality to work. |
| 63 | func DeployChaincode(n *Network, channel string, orderer *Orderer, chaincode Chaincode, peers ...*Peer) { |
| 64 | if len(peers) == 0 { |
| 65 | peers = n.PeersWithChannel(channel) |
| 66 | } |
| 67 | if len(peers) == 0 { |
| 68 | return |
| 69 | } |
| 70 | |
| 71 | PackageAndInstallChaincode(n, chaincode, peers...) |
| 72 | |
| 73 | // approve for each org |
| 74 | ApproveChaincodeForMyOrg(n, channel, orderer, chaincode, peers...) |
| 75 | |
| 76 | // wait for checkcommitreadiness returns ready status |
| 77 | CheckCommitReadinessUntilReady(n, channel, chaincode, n.PeerOrgs(), peers...) |
| 78 | |
| 79 | // after the chaincode definition has been correctly approved for each org, |
| 80 | // demonstrate the capability to inspect the discrepancies in the chaincode definitions |
| 81 | // by executing checkcommitreadiness with inspect flag, |
| 82 | // with intentionally altered values for chaincode definition parameters |
| 83 | InspectChaincodeDiscrepancies(n, channel, chaincode, n.PeerOrgs(), peers...) |
| 84 | |
| 85 | // commit definition |
| 86 | CommitChaincode(n, channel, orderer, chaincode, peers[0], peers...) |
| 87 | |
| 88 | // init the chaincode, if required |
| 89 | if chaincode.InitRequired { |
| 90 | InitChaincode(n, channel, orderer, chaincode, peers...) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | func PackageAndInstallChaincode(n *Network, chaincode Chaincode, peers ...*Peer) { |
| 95 | // create temp file for chaincode package if not provided |