使用LinearStateQueryCriteria时,

假设我有以下状态都具有相同的linearId,

S4 (unconsumed) created at t4
S3 (consumed)   created at t3
S2 (consumed)   created at t2
S1 (consumed)   created at t1

我如何检索具有StateStatus = CONSUMED的最新状态?是否可以按时间戳对结果列表进行排序?

最佳答案

您可以尝试为vaultQueryBy函数指定排序条件,例如:

 val sortAttribute = SortAttribute.Standard(Sort.VaultStateAttribute.RECORDED_TIME)
    val criteria = QueryCriteria.VaultQueryCriteria(stateRefs = listOf(stateRefs.first(), stateRefs.last()))
  val results = rpcOps.vaultQueryBy<IOUState>(criteria, sorting = Sort(setOf(Sort.SortColumn(sortAttribute, Sort.Direction.ASC))))

10-08 12:40