简体   繁体   English

Hyperledger Fabric-使用Node.js的HistoryQueryIterator

[英]Hyperledger Fabric- HistoryQueryIterator using nodejs

I am trying to create hyperledger chaincode using nodejs and fabric-shim is new to me. 我正在尝试使用nodejs创建超级账本链代码,fabric-shim对我来说是新的。 I am trying to fetch history of an asset using getHistoryForKey() . 我正在尝试使用getHistoryForKey()获取资产的历史记录。

I tried iterating through HistoryQueryIterator using while but i was not successful. 我尝试使用while通过HistoryQueryIterator进行迭代, HistoryQueryIterator成功。

@Transaction()
public async getAllHistory(ctx:Context,key:string):Promise<void>{
    const history = await ctx.stub.getHistoryForKey(key);
     while(history.next()){
         history.next().then(value =>{
            console.info("================>",value.toString());
         })
         .catch(err =>{
            console.info("ERROR",err);
         })
     }

}

The above code gives [object Object] . 上面的代码给出[object Object]

If someone could point me in the right direction it would be helpful. 如果有人可以指出正确的方向,那将会有所帮助。

You can find an example about how to use getHistoryForKey in the official Hyperledger Fabric samples ( chaincodes/marbles02). 您可以在Hyperledger Fabric官方示例(chaincodes / marbles02)中找到有关如何使用getHistoryForKey的示例。

https://github.com/hyperledger/fabric-samples/blob/release-1.4/chaincode/marbles02/node/marbles_chaincode.js https://github.com/hyperledger/fabric-samples/blob/release-1.4/chaincode/marbles02/node/marbles_chaincode.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Nodejs 实现 Hyperledger Fabric - How to implement Hyperledger Fabric using Nodejs Hyperledger Fabric NodeJS Shim-getHistoryForKey - Hyperledger Fabric NodeJS Shim - getHistoryForKey nodejs 中的 Hyperledger Fabric nodejs 链代码单元测试, - Hyperledger Fabric nodejs chaincode unit testing in nodejs, Hyperledger Fabric NodeJS客户端grpc问题 - Hyperledger Fabric NodeJS client grpc issue Hyperledger Fabric + NodeJS应用程序-查询但不调用 - Hyperledger Fabric + NodeJS app - Query but no Invoke Hyperledger Fabric和NodeJS-如何转换缓冲区 - Hyperledger Fabric and NodeJS - How to convert buffer 寻找一个端到端教程,以使用Hyperledger Fabric和Composer REST SERVER开发NodeJs区块链应用程序 - Looking for a End-to-End tutorial to develop a NodeJs Blockchain Appliation using Hyperledger Fabric and Composer REST SERVER 使用nodejs链码从hyperledger fabric v 1.4中的链码获取记录时如何设置偏移量和限制? - how to set offset and limit while fetching records from chaincode in hyperledger fabric v 1.4 using nodejs chaincode? 使用节点SDK在Hyperledger Fabric上升级Chaincode - Upgrade Chaincode on hyperledger fabric using node sdk Hyperledger Fabric Nodejs SDK Eventhub已关闭 - Hyperledger Fabric Nodejs SDK Eventhub has been shutdown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM