且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在搜索链中,我可以找到是否已消耗某些东西以及消耗了什么东西吗?

更新时间:2023-11-28 23:12:40

我需要了解您的用例以获得更好的答案.我相信您使用的参考状态不正确. ReferenceStates 用于需要访问事务中的状态数据而不使用它的情况.您可以将其视为存储主数据的对象,并且可以在不同的事务中引用它,而不必使用它们.

I would need to understand your use case to have a better answer. I believe you are using the reference state incorrectly. ReferenceStates are used in situations where you want to have access to a state's data in a transaction without consuming it. You could think of it as something that stores master data and you can refer to it in different transactions without necessarily consuming it.

根据您的要求,您可以使用 Vault.StateStatus.ALL 条件执行vaultQuery,无论是否消耗该状态,都将获取状态.然后,您可以检查状态以识别其是否已消耗.或者只是获取已消耗/未消耗并根据返回的结果数进行检查.无论哪种方式.

As per your requirement, you could do a vaultQuery with Vault.StateStatus.ALL criteria, which would fetch the state irrespective it's consumed to not. You could then check the status to identify if it's consumed. Or just fetch the Consumed/ Unconsumed and check based on the number of results returned. Either way you like.

尽管可以将trnx链向后移动,但我不知道直接的API可以为您提供哪个事务消耗了状态.您可能需要为此构建自定义解决方案.

Though one could walk the trnx-chain in backward direction, I am not aware of a direct API which can give you which transaction consumed a state. You might perhaps have to build a custom solution for this.