我是 hyperledger fabric 的新手。我已经下载了 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
};
错误:
Failed to invoke successfully :: TypeError: fabric_client.newEventHub is not a function
当我试图在 index.t.ds 中查找 newEventHub 时,我找不到该函数。谁能帮我解决这个问题。提前致谢。
最佳答案
我认为他们已经用 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());
这应该可以解决问题。
关于node.js - 无法找到新的 EventHub 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51436123/