【发布时间】:2019-03-13 05:30:27
【问题描述】:
我正在尝试通过 Hyperledger Fabric 中的第一个演示“编写您的第一个应用程序”https://hyperledger-fabric.readthedocs.io/en/release-1.2/write_first_app.html。我成功运行了查询部分(queryAllCars 和 queryCar 方法)。 我在更新分类帐部分时遇到问题。我就是这样做的:
-
将值放入invoke.js 文件中:
var request = { //targets: let default to the peer assigned to the client chaincodeId: 'fabcar', fcn: 'createCar', args: ['CAR10', 'Chevy', 'Volt', 'Red', 'Nick'], chainId: 'mychannel', txId: tx_id}; 运行节点invoke.js并进入终端:
商店 路径:/home/krystian/hyperledger-test/fabric-samples/fabcar/hfc-key-store
从持久化成功加载user1
分配 transaction_id:0dfca05d6f19187275c6a31febc81429ddca3a284fd590c631961a10f8da5aee
交易提案不错
成功发送提案并收到 ProposalResponse:状态 - 200,消息 - ""
调用失败 成功 :: 错误:eventthub ::14 出现问题 不可用:TCP 写入失败
at createStatusError (/home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:64:15) at ClientDuplexStream._emitStatusIfDone (/home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:270:19) at ClientDuplexStream._receiveStatus (/home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:248:8) at /home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:804:12
这是我的 package.json
{
"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": "^1.2.1",
"fabric-client": "^1.2.1",
"grpc": "^1.15.1"
},
"author": "Anthony O'Dowd",
"license": "Apache-2.0",
"keywords": [
"Hyperledger",
"Fabric",
"Car",
"Sample",
"Application"
]
}
这是 invoke.js 崩溃的一部分:
let event_hub = fabric_client.newEventHub();
event_hub.setPeerAddr('grpc://localhost:7053');
// using resolve the promise so that result status may be processed
// under the then clause rather than having the catch clause process
// the status
let txPromise = new Promise((resolve, reject) => {
let handle = setTimeout(() => {
event_hub.disconnect();
resolve({event_status : 'TIMEOUT'}); //we could use reject(new Error('Trnasaction did not complete within 30 seconds'));
}, 3000);
**event_hub.connect();
event_hub.registerTxEvent(transaction_id_string, (tx, code) => {
// this is the callback for transaction event status
// first some clean up of event listener
clearTimeout(handle);
event_hub.unregisterTxEvent(transaction_id_string);**
event_hub.disconnect();
我尝试删除 fabcar/node_modules 并再次运行 npm install。 我也试过运行 sudo node invoke.js 。 我完成了构建您的第一个网络的教程,一切正常。
节点版本 v8.9.0
NPM 版本 5.5.1
我正在使用 Linux Mint
当 initLedger 方法和查询工作没有问题时,更新分类帐可能会出现问题?
【问题讨论】:
-
我已经尝试在 Linux Mint 的新实例上做同样的事情,并且工作起来就像一个魅力。但是我还是很好奇我第一次犯错的地方。
标签: hyperledger-fabric hyperledger grpc