首页 > 解决方案 > 找不到 newEventHub 函数

问题描述

我是超级账本结构的新手。我已经下载了fabric v1.2.0,并尝试从fabric-sample 文件夹中运行fabcar 示例。我对链码的查询很顺利,但是当我尝试调用链码时,我从 cmd 中得到了以下错误。

这是我对链码的要求

var request = {
    //targets: let default to the peer assigned to the client
    chaincodeId: 'fabcar',
    fcn: 'changeCarOwner',
    args: ['CAR4', 'Dave'],
    chainId: 'mychannel',
    txId: tx_id
};

错误:

调用失败 :: TypeError: fabric_client.newEventHub is not a function

当我试图在index.t.ds中找到 newEventHub 时,我找不到该函数。任何人都可以帮我解决这个问题。在此先感谢。

标签: node.jshyperledger-fabric

解决方案


我认为他们已经用ChannelEventHub替换了 EventHub 类。

您可以使用以下内容更新 invoke.js 文件:

在第 105 行:

let event_hub = channel.newChannelEventHub('localhost:7051');
// event_hub.setPeerAddr('grpc://localhost:7053');

在第 130 行:

console.log('The transaction has been committed on peer ' + event_hub.getPeerAddr());

那应该解决它。


推荐阅读