在足够多的组织批准了链码定义后,任意一个组织就可以将链码定义提交到通道。(如果大多数通道成员都批准了该定义,提交事务就会成功,反之,如果没有先让大多数通道成员批准该链码定义,提交事务就会失败)
提交命令为:
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --output json
- --output json 返回一串json结果,显示通道成员是否已批准该链码定义。
接下来我们可以通过{ "Approvals": { "Org1MSP": true, "Org2MSP": true } }
peer lifecycle chaincode commit
命令将链码定义提交到通道。提交命令也需要由组织管理员提交。peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name basic --version 1.0 --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"