本文主要是介绍HyperLedger-fabric 实践之fabric-sample-fabcar,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
HyperLedger-fabric
fabric-sample-fabcar
官方文档:
http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html
这里主要讲述本人遇到的问题:
问题一:
curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-preview
上面命令由于某些原因不能执行成功,解决如下:
访问下面页面进行下载该shell脚本:
https://github.com/hyperledger/fabric/blob/master/scripts/bootstrap.sh
之后执行它:
sudo chmod +x bootstrap.sh
./bootstrap.sh
问题二:
请注意,这里不要使用root权限运行。
在运行 npm install
出现不能运行,或者运行成功但执行后面命令却失败的问题。下面是我的解决方案:
删除fabcar文件夹下的node_modules文件夹(你可以选择重命名)后,
执行npm install
。
如果问题还在,那么你需要一份新的package.json
文件,这里暂时给出我的package.json
文件内容,当你使用的时候可能已过时,建议重新下载fabric-sample进行拷贝(或者重新开始):
{"name": "fabcar","version": "1.0.0","description": "Hyperledger Fabric Car Sample Application","main": "fabcar.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1"},"dependencies": {"fabric-ca-client": "unstable","fabric-client": "unstable","grpc": "^1.6.0"},"author": "Anthony O'Dowd","license": "Apache-2.0","keywords": ["Hyperledger","Fabric","Car","Sample","Application"]
}
执行npm install
问题三:
执行 node registerUser.js
出现下面错误。
fabric-ca request register failed with errors [[{"code":0,"message":"No identity type provided. Please provide identity type"}]]
大概的意思是需要我们提供一个可验证的type。
只需修改registerUser.js
一条语句。下面是修改完后的句子。
return fabric_ca_client.register({enrollmentID: 'user1', affiliation: 'org1.department1',role:'client'}, admin_user);
主要就是增加:role:'client'
问题四:
执行:
CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./sacc
出现:[shim] userChaincodeStreamGetter -> ERRO 003 Error trying to connect to local peer: context deadline exceeded
将命令换成:
CORE_PEER_ADDRESS=peer:7051 CORE_CHAINCODE_ID_NAME=mycc:0 ./sacc
祝你好运!
这篇关于HyperLedger-fabric 实践之fabric-sample-fabcar的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!