Detailed analysis of Fabric2.3 peer chaincode invoke

Detailed analysis of Fabric2.3 peer chaincode invoke

When testing the asset transfer model (asset-transfer-basic) of Fabric-samples, after the Go smart contract is packaged, installed, approved, and submitted to the channel, it is necessary to call the writtenchaincodeTo initialize the built-in written ledger, that is, InitLedgerthe function. The instruction to initialize and call this function is very long, so I specially set it up separately for learning and recording:

//该指令用于将已经提交到通道的链码进行一个用的调
peer chaincode invoke 
//本地端口
-o localhost:7050 
//验证TLS连接时使用的排序节点主机名
--ordererTLSHostnameOverride orderer.example.com 
//与排序节点通信时使用 TLS
--tls
//包含排序端点的 PEM 编码可信证书的文件路径
--cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" 
//在哪个通道上执行,应该是已经提交完成的通道上
-C mychannel 
//链码名字
-n basic 
//要连接的背书节点端口地址
--peerAddresses localhost:7051 
//如果TLS启用了,背书节点需要链接到TLS根证书的路径。
--tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" 
//第二个背书节点的端口地址
--peerAddresses localhost:9051 
//第二个背书节点需要链接到TLS根证书的路径
--tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" 
//JSON 格式的链码的构造函数消息
-c '{"function":"InitLedger","Args":[]}'

Detailed analysis is in the comments.

Guess you like

Origin blog.csdn.net/weixin_42918620/article/details/120458879