是否可以通过Vault查询在vault_state中看到事务消耗的时间?
答案 0 :(得分:0)
是的。您可以使用查询结果的statesMetadata
字段来找到消耗状态的时间。
在流程中:
@Suspendable
override fun call() {
val results = serviceHub.vaultService.queryBy(ContractState::class.java)
val statesAndMetadata = results.states.zip(results.statesMetadata)
statesAndMetadata.forEach { (stateAndRef, metadata) ->
val consumedTime = metadata.consumedTime
}
}
在RPC客户端中:
fun main(args: Array<String>) {
require(args.size == 1) { "Usage: TemplateClient <node address>" }
val nodeAddress = parse(args[0])
val client = CordaRPCClient(nodeAddress)
// Can be amended in the com.template.MainKt file.
val cordaRPCOps = client.start("user1", "test").proxy
val results = cordaRPCOps.vaultQueryBy<ContractState>()
val statesAndMetadata = results.states.zip(results.statesMetadata)
statesAndMetadata.forEach { (stateAndRef, metadata) ->
val consumedTime = metadata.consumedTime
}
}