我制作了一个CustomvaultQuery.Service类,用于从数据库中获取详细信息以在流中使用它,但是在日志中,它显示IllegalArgument,因为在Corda中找不到CustomvaultQuery $ Service,因为它是@CordaService
答案 0 :(得分:0)
请查看有关Corda服务代码的以下示例:
private fun directPayment() {
val ourIdentity = ourIdentity()
serviceHub.vaultService.trackBy<PaymentRequestState>().updates.subscribe {
update: Vault.Update<PaymentRequestState> -> update.produced.forEach{
message: StateAndRef<PaymentRequestState> ->
val state = message.state
if (ourIdentity == serviceHub.networkMapCache.getPeerByLegalName(CordaX500Name("BankOperator", "Toronto", "CA"))!!) {
executor.execute {
log.info("Directing to message $state")
serviceHub.startFlow(PaymentFlowInitiator())
}
}
}
}
}
这正是您正在寻找的数据库查询服务。 完整代码位于:https://github.com/corda/samples-kotlin/blob/master/Features/cordaService-autopayroll/workflows-kotlin/src/main/kotlin/net/corda/examples/autopayroll/flows/AutoPaymentService.kt