peer lifecycle chaincode commit
管理员可以使用peer lifecycle chaincode commit
子命令
向指定通道提交链码定义
peer lifecycle chaincode commit
是Hyperledger Fabric 2.0新增的命令。
使用方法
peer lifecycle chaincode commit [flags]
参数说明:
- flags:可用标志,包括局部标志和全局标志
局部标志
peer lifecycle chaincode commit
命令的可用局部标志如下:
--channel-config-policy string 链码背书策略
-C, --channelID string 通道ID
--collections-config string collection文件路径
--connectionProfile string Fabric网络连接配置文件路径
-E, --endorsement-plugin string 用于此链码的背书插件名称
-h, --help 命令的帮助信息
--init-required 是否需要调用链码的init方法
-n, --name string 链码名称
--peerAddresses stringArray 要连接的peer节点
--sequence int 通道链码定义序列号,默认值:1
--signature-policy string 签名策略
--tlsRootCertFiles stringArray 如果启用了TLS,该标志用来声明所连接peer节点的TLS根证书
-V, --validation-plugin string 用于此链码的验证插件名称
-v, --version string 链码版本
--waitForEvent 是否等待peer节点交易提交成功,默认值:true
--waitForEventTimeout duration 等待超时设置,默认值:30s
全局标志
peer lifecycle chaincode commit
命令的可用全局标志如下:
--cafile string PEM编码的CA证书文件路径
--certfile string 双向TLS通讯所需的PEM编码的X509证书文件路径
--clientauth 与排序节点的通讯是否启用双向TLS
--connTimeout duration 客户端连接超时,默认值:3秒
-h, --help 帮助信息
--keyfile string 双向TLS通讯所需的PEM编码的私钥文件
-o, --orderer string 排序节点地址
--ordererTLSHostnameOverride string 验证TLS连接时使用的排序节点主机名
--tls 与排序节点通信时是否启用TLS
示例代码
一旦足够数量的机构批准了链码定义(默认情况下要求超过半数),一个机构就
可以使用peer lifecycle chaincode commit
命令向通道提交链码定义。
下面的命令需要指向通道中的其他机构中的peer节点以便为链码定义收集机构背书:
export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name mycc --version 1.0 --sequence 1 --init-required --tls --cafile $ORDERER_CA --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:9051
输出结果如下:
2019-03-18 16:14:27.258 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [b6f657a14689b27d69a50f39590b3949906b5a426f9d7f0dcee557f775e17882] committed with status (VALID) at peer0.org2.example.com:9051
2019-03-18 16:14:27.321 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [b6f657a14689b27d69a50f39590b3949906b5a426f9d7f0dcee557f775e17882] committed with status (VALID) at peer0.org1.example.com:7051