问题描述
我已经按照以下步骤使用 test-network 在我的机器上创建了 hyperledger 2.2 设置
- 使用以下命令,在
/fabric-samples/test-network
目录以及org1
、org2
和orderer
的容器中,与它们的 CA 相关。
./network.sh up createChannel -ca -c mychannel -s couchdb -i 2.2.0
- 使用 在
mychannel
上部署链码
./network.sh deployCC -ccn basic1 -ccp ../asset-transfer-basic/chaincode-go/ -ccl go
./addOrg3.sh up -ca -c channel1 -s couchdb -i 2.2.0
在那之后想在 channel1
上部署 chaicode 但是我当我使用命令部署链码时它尝试在 org1
和 org2
上部署链码这使它失败了请任何人建议我如何仅在 channel1
和 org1
上的 org3
上部署链代码,这些链代码加入了 channel1
。
./network.sh deployCC -c channel1 -ccn basic1 -ccp ../asset-transfer-basic/chaincode-go/ -ccl go
解决方法
来自 test network documentation,“deployCC 子命令将在 peer0.org1.example.com 和 peer0.org2.example.com 上安装资产转移(基本)链代码,然后在指定的通道上部署链代码使用频道标志(如果未指定频道,则使用 mychannel)。”
您应该仍然能够部署您的链代码,但您需要直接使用 Fabric peer 命令而不是测试网络脚本。 Deploying a smart contract to a channel tutorial 中描述了该过程,Fabric chaincode lifecycle documentation 中有更多详细信息。
,./test-network/network.sh deployCC ...
调用 ./test-network/scripts/deployCC.sh
在此 deployCC.sh
中,在 org1
和 org2
中部署链代码是硬编码的。
它的工作原理是将 org1 & org2
更改为 org1 & org3
- ./test-network/scripts/deployCC.sh
...
## package the chaincode
packageChaincode
## Install chaincode on peer0.org1 and peer0.org3
infoln "Installing chaincode on peer0.org1..."
installChaincode 1
infoln "Install chaincode on peer0.org3..."
installChaincode 3
## query whether the chaincode is installed
queryInstalled 1
## approve the definition for org1
approveForMyOrg 1
## check whether the chaincode definition is ready to be committed
## expect org1 to have approved and org3 not to
checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org3MSP\": false"
checkCommitReadiness 3 "\"Org1MSP\": true" "\"Org3MSP\": false"
## now approve also for org3
approveForMyOrg 3
## check whether the chaincode definition is ready to be committed
## expect them both to have approved
checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org3MSP\": true"
checkCommitReadiness 3 "\"Org1MSP\": true" "\"Org3MSP\": true"
## now that we know for sure both orgs have approved,commit the definition
commitChaincodeDefinition 1 3
## query on both orgs to see that the definition committed successfully
queryCommitted 1
queryCommitted 3
## Invoke the chaincode - this does require that the chaincode have the 'initLedger'
## method defined
if [ "$CC_INIT_FCN" = "NA" ]; then
infoln "Chaincode initialization is not required"
else
chaincodeInvokeInit 1 3
fi
...