如何在Hyperledger架构中针对链码获取所有交易历史记录 [英] How to get all transaction history against a chaincode in Hyperledger fabric

查看:250
本文介绍了如何在Hyperledger架构中针对链码获取所有交易历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够在Hyperledger(结构实现)中进行交易.我想查看用户通过传递用户密钥启动的所有交易及其有效负载详细信息.

I am able to do transactions in Hyperledger (fabric implementation). I want to see all the transactions and its payload details initiated by a user by passing the user's key.

例如:

A transfers 10 units to B
A transfers 5 units to C
D transfers 8 units to A

当我通过A的密钥时,结构必须向我提供A的所有交易. 有什么办法吗?还是应该使用哪个Fabric API函数调用?

When I pass A's key then fabric must provide me all the transactions of A. Is there any way? Or which fabric API function call should I use?

推荐答案

您可以在链码中开发适当的索引和查询功能.

You can develop the proper indexing and query function in your chaincode.

对于每笔交易,您都将其详细信息存储在内部键/值存储区(stub.PutState)中,并以用户为键,并返回与查询中的用户相关的所有交易(stub.GetState).

Meaning for each transaction you store its details in the internal key/value store (stub.PutState) with the user as key and return all the transactions associated to a user in your query (stub.GetState).

这篇关于如何在Hyperledger架构中针对链码获取所有交易历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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