如何使用节点SDK在Hyperledger Fabric中使用区块哈希获取资产历史记录 [英] How to get history of asset with block hash in hyperledger fabric using node sdk

查看:177
本文介绍了如何使用节点SDK在Hyperledger Fabric中使用区块哈希获取资产历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些资产的状态得到更新,并且我想使用previous_hash和当前的Block_hash获取该资产的历史记录.我正在使用CouchDB作为Hyperledger Fabric的状态数据库.

I have assets whose state get updated and I want get history of that asset with previous_hash and current Block_hash. I am using CouchDB as State DB of Hyperledger Fabric.

我尝试了fabcar示例函数'getHistoryForAsset',但是它只能给我 TxID ,但我需要与此相关的Block hash.

I tried fabcar example function 'getHistoryForAsset' but it can give me only TxID but I need Block hash with this.

有人可以帮助我吗?

谢谢

推荐答案

使用交易ID,您可以在系统 qscc 链代码上调用(评估) GetBlockByTxID 交易功能得到包含该交易的区块.它期望以交易ID作为参数,并返回 common.Block protobuf响应有效负载.

Using the transaction ID you can call (evaluate) the GetBlockByTxID transaction function on the system qscc chaincode to get the block that contained that transaction. It expects a transaction ID as an argument and returns a common.Block protobuf response payload.

https://github.com/hyperledger/fabric-protos/blob/f44816d6f621f1f7615cb4fc65643791eb6d8ce6/common/common.proto#L142

请注意,一个块仅包含前一个块的哈希,而不包含其本身的哈希.

Note that a block only contains the hash of the previous block, not the hash of itself.

这篇关于如何使用节点SDK在Hyperledger Fabric中使用区块哈希获取资产历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆