Corda view consumed states in terminal

青春壹個敷衍的年華 提交于 2020-07-19 01:59:51

问题


is there an easy way to view the consumed states in the terminal with the CordaRPCOps interface? It seems that vaultQuery returns unconsumed states by default and I can't figure out how to use vaultQueryBy or anything with the criteria.

I know that there should be consumed states because I can see them with H2


回答1:


Hi you could always write a short API to expose the states:

there is a sample for /asset in corda existing samples:

here is a code snippet api for your scenario:

@GET
@Path("asset")
@Produces(MediaType.APPLICATION_JSON)
fun getAssets(): List<StateAndRef<ContractState>> {
    val consumedCriteria = QueryCriteria.VaultQueryCriteria(Vault.StateStatus.CONSUMED)
    return services.vaultQueryBy<ContractState>(consumedCriteria).states
}



回答2:


As Ricky says, you'll have to provide an API or write a client to speak to your CorDapp via RPC (e.g. https://github.com/corda/cordapp-example/blob/release-V1/kotlin-source/src/main/kotlin/com/example/client/ExampleClientRPC.kt).

In theory, run vaultQueryByCriteria contractStateType: com.example.state.IOUState, criteria: { Vault.StateStatus.CONSUMED } could work. However, in vaultQueryByCriteria, the criteria parameter is of type QueryCriteria, which is an abstract class. There is no way currently in the shell to specify which concrete subclass of QueryCriteria you wish to use.

I have raised an issue here: https://github.com/corda/corda/issues/2351.



来源:https://stackoverflow.com/questions/48195934/corda-view-consumed-states-in-terminal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!