如何获取传递给交易的历史状态参数 [英] How to get the parameters passed to the transaction for the historical states

查看:79
本文介绍了如何获取传递给交易的历史状态参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取负责新状态的操作.简而言之,我想获得传递给invoke方法的函数名.当我查看历史状态时,我可以获取其值,时间戳,交易ID等,但不能获取负责该交易的参数.

I am trying to get the operation which is responsible for the new state. In simple words, I want to get the function name passed to the invoke method. When I am looking into the historical states I am able to fetch its value, timestamp, transaction ID, etc. but not the parameters which are responsible for that transaction.

我知道我们可以从块历史中获取参数,但是对于状态,我需要它.

I know we can get the parameters from the block history, but I need it for the states.

有什么办法可以从链码方面实现这一目标?

Is there any way to achieve this from the chaincode side?

推荐答案

我也想知道您的方法.但这是我的看法,我们可以在sdk中注册一个事件监听器(使用 registerChaincodeEvent 方法)并创建一个事件(使用 setEvent 方法),其中有效负载将是 getFunctionAndParameters 方法的结果.而且,您可能可以继续将这些结果存储到数据存储中,以便以后全部获取.

I would like to know about your approach as well. However this would be my take on this,we can probably register an event listener in our sdk (using registerChaincodeEvent method) and create an Event (using setEvent method) in our chaincode ,wherein our payload would be the result from getFunctionAndParameters method. And you can probably keep storing these results into a datastore to later fetch them all.

或者:您可以简单地通过shim.success将 getFunctionAndParameters 的结果作为键发送回响应对象.

Alternatively: You can simply send back the result of getFunctionAndParameters as a key in the response object via shim.success.

这篇关于如何获取传递给交易的历史状态参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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