serviceHub.vaultQueryService.queryBy默认情况下返回所有相关状态? [英] serviceHub.vaultQueryService.queryBy returns all related states by default?

查看:28
本文介绍了serviceHub.vaultQueryService.queryBy默认情况下返回所有相关状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用以下代码通过linearId检索状态时,我得到了2条记录,其中一条是消耗的,另一条是未消耗的.最初的linearId是从Web api传入的.

  val linearId:UniqueIdentifier = UniqueIdentifier(null,UUID.fromString(legalContractState.legalContract.linearId))val linearIds = listOf(linearId)val linearStateCriteria = QueryCriteria.LinearStateQueryCriteria(linearId = listOf(linearIds.first(),linearIds.last()))val状态= serviceHub.vaultQueryService.queryBy(LegalContractState :: class.java,linearStateCriteria).statesval inputState:StateAndRef< LegalContractState>.= serviceHub.vaultQueryService.queryBy(LegalContractState :: class.java,linearStateCriteria).states.single() 

但是从 vault api页面上的示例代码中,它表示返回一个基于linearId的未消耗状态,我还检查了H2数据库VAULT_STATES表中的数据,有2条记录,一条具有CONSUMED_TIMESTAMP,其STATE_STATUS为1,但另一条CONSUMED_TIMESTAMP为null,STATE_STATUS为0.这是一个非共享状态,这意味着仅存储在我的数据库中,并且我对其执行了一次更新,因此理想情况下在db中具有一个消耗状态和一个新输出状态.所以现在我不确定这里出了什么问题.

查询给定线性id的未消耗线性状态:

  val linearIds = issueStates.states.map {it.state.data.linearId} .toList()val条件= LinearStateQueryCriteria(linearId = listOf(linearIds.first(),linearIds.last()))val结果= vaultQuerySvc.queryBy< LinearState>(条件) 

解决方案

这是一个错误,将在M14版本中修复.参见 https://github.com/corda/corda/issues/949 ./p>

When I tried to use below codes to retrieve the state by linearId, I got 2 records returned, one is the consumed one, the other is the unconsumed one. The initial linearId was passed in from web api.

val linearId: UniqueIdentifier = UniqueIdentifier(null, UUID.fromString(legalContractState.legalContract.linearId))
val linearIds = listOf(linearId)
val linearStateCriteria = QueryCriteria.LinearStateQueryCriteria(linearId = listOf(linearIds.first(), linearIds.last()))
val states = serviceHub.vaultQueryService.queryBy(LegalContractState::class.java, linearStateCriteria).states
val inputState: StateAndRef<LegalContractState> = serviceHub.vaultQueryService.queryBy(LegalContractState::class.java, linearStateCriteria).states.single()

But from a sample code on the vault api page, it says this will return an unconsumed state based on a linearId, I also checked the data in H2 database VAULT_STATES table, there are 2 records, one has a CONSUMED_TIMESTAMP and its STATE_STATUS is 1, but the other one CONSUMED_TIMESTAMP IS null and STATE_STATUS is 0. This is one unshared state which means only stored in my database, and I executed one update for it, so ideally have one consumed state and one new output state in db. So now I am not sure what's wrong here.

Query for unconsumed linear states for given linear ids:

val linearIds = issuedStates.states.map { it.state.data.linearId }.toList()
val criteria = LinearStateQueryCriteria(linearId = listOf(linearIds.first(), linearIds.last()))
val results = vaultQuerySvc.queryBy<LinearState>(criteria)

解决方案

This is a bug that will be fixed in release M14. See https://github.com/corda/corda/issues/949.

这篇关于serviceHub.vaultQueryService.queryBy默认情况下返回所有相关状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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