MCPcopy
hub / github.com/hyperledger/fabric / DeployChaincode

Function DeployChaincode

integration/nwo/deploy.go:63–92  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
63func 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
94func PackageAndInstallChaincode(n *Network, chaincode Chaincode, peers ...*Peer) {
95 // create temp file for chaincode package if not provided

Callers 15

deployChaincodeFunction · 0.92
upgradeChaincodeFunction · 0.92
lifecycle_test.goFile · 0.92
interop_test.goFile · 0.92
data_purge_test.goFile · 0.92
pluggable_test.goFile · 0.92
smartbft_test.goFile · 0.92
deployChaincodeFunction · 0.92
rsaca_test.goFile · 0.92
msp_test.goFile · 0.92
idemix_test.goFile · 0.92

Calls 8

CommitChaincodeFunction · 0.85
InitChaincodeFunction · 0.85
PeersWithChannelMethod · 0.80
PeerOrgsMethod · 0.80
ApproveChaincodeForMyOrgFunction · 0.70

Tested by 4

deployChaincodeFunction · 0.74
upgradeChaincodeFunction · 0.74
deployChaincodeFunction · 0.74
deployChaincodeMethod · 0.74