Hyperledger背书策略和调用chaincode错误(不更新分类帐)



我使用的是Hyperledger Fabric 1.4.8

我已经使用以下命令部署了一个链码:

peer chaincode install -n davidcodeEndorseAnd -v vAlfaBeta1 -p github.com/chaincode/chaincode_example02/go/
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n davidcodeEndorseAnd -v vAlfaBeta1 -c '{"Args":["init","a","0","b","10000"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"

背书参数:AND ('Org1MSP.peer','Org2MSP.peer').

当我尝试使用以下命令调用chaincode时,我得到一个200响应,但值没有更新:

peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C mychannel -n davidcodeEndorseAnd  -c '{"Args":["invoke","a","b","900"]}

执行输出:

root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n davidcodeEndorseAnd -c '{"Args":["query","a"]}'
0
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C mychannel -n davidcodeEndorseAnd -c '{"Args":["invoke","b","a","900"]}'
2021-07-28 19:55:55.757 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n davidcodeEndorseAnd -c '{"Args":["query","a"]}'
0

注意:我正在使用织物样品的链码样品:/fabric-samples/chaincode/chaincode_example02/go

我尝试了以下调用命令,但没有成功:

peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n davidcodeEndorseAnd --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --tlsRootCertFiles "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"Args":["invoke","a","b","100"]}'

执行输出:

Error: error sending transaction for invoke: could not send: EOF - proposal response: version:1 response:<status:200 > payload:"n 14IU17b3633522260301%347+32sv264s25623204z17251210163472733543573563532222101ng22@n23davidcodeEndorseAnd22)n07n01a22021016n07n01b2202101632tn01a3204-10032nn01b32051010022#n04lscc2233n31n23davidcodeEndorseAnd2202101632031031001"!2223davidcodeEndorseAnd32nvAlfaBeta1" endorsement:<endorser:"n07Org1MSP2225206-----BEGIN CERTIFICATE-----nMIICKDCCAc6gAwIBAgIQWdbqnSydfjum3L3K+6YISTAKBggqhkjOPQQDAjBzMQswnCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZynYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eunb3JnMS5leGFtcGxlLmNvbTAeFw0yMTA3MjgxNzU2MDBaFw0zMTA3MjYxNzU2MDBanMGoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TnYW4gRnJhbmNpc2NvMQ0wCwYDVQQLEwRwZWVyMR8wHQYDVQQDExZwZWVyMC5vcmcxnLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEkcU5Enp3gweinAM4r7IHPbIjaEI+AH+tM2teIZDHGJGDjeBtjA/vLSH2ngb/9H9DiG2agKmTHJsifnHxppCcUuJqNNMEswDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jnBCQwIoAgnaRyyHIgBgevWkF1kAgjunZH1joAPFpRTZ2gy+X2RLIwCgYIKoZIzj0EnAwIDSAAwRQIhAOyZZ+sdZg+S+HgyRqg7lO716OYc59/Yc9Iuabvs+h7ZAiBFIN2Jn3894dwxHteNaD9+FF6HNklKt9tWPnKdJ4szuOQ==n-----END CERTIFICATE-----n" signature:"0D02 :252206j`345217362:233330262313325201367245q3311426417Z303722J2762455n02 t9227AW-M31124200324242E30026w00enJN340253vR316*2042309Z202" > 
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# 

我已经成功地更新了分类帐:

Org1下的执行输出:

root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n davidcodeEndorseAnd -c '{"Args":["query","a"]}'
-10
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n davidcodeEndorseAnd --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","b","a","100"]}' 
2021-07-28 20:17:56.431 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n davidcodeEndorseAnd -c '{"Args":["query","a"]}'
90
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# 

Query Execution under Org2:

root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n davidcodeEndorseAnd -c '{"Args":["query","a"]}'
90
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n davidcodeEndorseAnd -c '{"Args":["query","b"]}'
9910
root@50179e3b3e32:/opt/gopath/src/github.com/hyperledger/fabric/peer# 

问题是我错过了调用命令排序的以下参数:

--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

相关内容

  • 没有找到相关文章

最新更新