- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Corda 中,我尝试使用 CordaRPCOps 的 startFlowDynamic 调用流程,但在调用启动流程时收到此错误:
A FlowLogicRef cannot be constructed for FlowLogic of type com.r3.corda.finance.obligation.flows.CreateObligation$Initiator: due to missing constructor for arguments: [class net.corda.core.contracts.Amount, class com.r3.corda.finance.obligation.flows.CreateObligation$InitiatorRole, class net.corda.core.identity.Party, class java.lang.Integer, class java.lang.Boolean]
我见过这个thread of the same exception但这并不能解决我的问题。我认为我传递给流程的参数是正确的,但不确定为什么我仍然遇到此异常。
这是我的 ObligationApi.kt
,它接受我的表单输入,然后触发 issue-obligation
,然后触发 CreateObligation
流程:
package com.r3.corda.finance.obligation
import com.r3.corda.finance.obligation.flows.CreateObligation
import com.r3.corda.finance.obligation.states.Obligation
import net.corda.core.contracts.Amount
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.utilities.getOrThrow
import java.util.*
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
@Path("obligation")
class ObligationApi(val rpcOps: CordaRPCOps) {
private val myIdentity = rpcOps.nodeInfo().legalIdentities.first()
private val notaryIdentity = rpcOps.notaryIdentities().first()
@GET
@Path("me")
@Produces(MediaType.APPLICATION_JSON)
fun me() = mapOf("me" to myIdentity)
@GET
@Path("peers")
@Produces(MediaType.APPLICATION_JSON)
fun peers() = mapOf("peers" to rpcOps.networkMapSnapshot()
.filter { nodeInfo ->
nodeInfo.legalIdentities.first() != myIdentity
&& nodeInfo.legalIdentities.first() != notaryIdentity
&& nodeInfo.legalIdentities.first().name.organisation != "Oracle"
}
.map { it.legalIdentities.first().name.organisation })
@GET
@Path("all-nodes")
@Produces(MediaType.APPLICATION_JSON)
fun allNodes() = mapOf("allNodes" to rpcOps.networkMapSnapshot()
.filter { nodeInfo ->
nodeInfo.legalIdentities.first() != myIdentity
}
.map { it.legalIdentities.first().name.organisation })
@GET
@Path("issue-obligation")
fun issueObligation(@QueryParam(value = "role") role: String,
@QueryParam(value = "party") party: String,
@QueryParam(value = "currency") currency: String,
@QueryParam(value = "amount") amount: Int,
@QueryParam(value = "duedate") duedate: Int
): Response {
println("!! TESTING - ObligationApi.kt 1.0")
println(myIdentity)
// 1. Get party objects for the counterparty.
val obligorIdentity = rpcOps.partiesFromName(party, exactMatch = false).singleOrNull()
?: throw IllegalStateException("Couldn't lookup node identity for $party.")
// 2. Create an amount object.
val issueAmount = Amount(amount.toLong() * 100, Currency.getInstance(currency))
// 3. Get role class
val roleClass: CreateObligation.InitiatorRole
if (role == "OBLIGEE") {
roleClass = CreateObligation.InitiatorRole.OBLIGEE
} else {
roleClass = CreateObligation.InitiatorRole.OBLIGOR
}
// 4. Start the IssueObligation flow. We block and wait for the flow to return.
val (status, message) = try {
println("!! TESTING - ObligationApi.kt 1.1")
val flowHandle = rpcOps.startFlowDynamic(
CreateObligation.Initiator::class.java,
issueAmount,
roleClass,
obligorIdentity,
duedate,
true
)
println("!! TESTING - ObligationApi.kt 1.2")
val result = flowHandle.returnValue.getOrThrow()
flowHandle.close()
Response.Status.CREATED to "Transaction id ${result.id} committed to ledger.\n${result.outputs}"
} catch (e: Exception) {
Response.Status.BAD_REQUEST to e.message
}
// 4. Return the result.
return Response.status(status).entity(message).build()
}
@GET
@Path("obligations")
@Produces(MediaType.APPLICATION_JSON)
fun obligations(): List<Obligation<*>> {
println("!! TESTING - ObligationApi.kt 2.0")
val statesAndRefs = rpcOps.vaultQuery(Obligation::class.java).states
return statesAndRefs
.map { stateAndRef -> stateAndRef.state.data }
.map { state ->
// We map the anonymous lender and borrower to well-known identities if possible.
val possiblyWellKnownLender = rpcOps.wellKnownPartyFromAnonymous(state.obligee) ?: state.obligee
val possiblyWellKnownBorrower = rpcOps.wellKnownPartyFromAnonymous(state.obligor) ?: state.obligor
println("!! TESTING - ObligationApi.kt 2.1")
Obligation(state.faceAmount,
possiblyWellKnownBorrower,
possiblyWellKnownLender,
state.dueBy,
state.createdAt,
state.settlementMethod,
state.payments,
state.linearId)
}
}
}
我的CreateObligation.kt
流程:
package com.r3.corda.finance.obligation.flows
import co.paralleluniverse.fibers.Suspendable
import com.r3.corda.finance.obligation.commands.ObligationCommands
import com.r3.corda.finance.obligation.contracts.ObligationContract
import com.r3.corda.finance.obligation.states.Obligation
import com.r3.corda.finance.obligation.types.Money
import net.corda.confidential.SwapIdentitiesFlow
import net.corda.core.contracts.Amount
import net.corda.core.flows.*
import net.corda.core.identity.AbstractParty
import net.corda.core.identity.Party
import net.corda.core.serialization.CordaSerializable
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.ProgressTracker
import net.corda.core.utilities.seconds
import java.security.PublicKey
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneOffset
object CreateObligation {
@CordaSerializable
enum class InitiatorRole {
OBLIGOR,
OBLIGEE
}
@InitiatingFlow
@StartableByRPC
class Initiator<T : Money>(
private val amount: Amount<T>,
private val role: InitiatorRole,
private val counterparty: Party,
private val dueBy: Instant? = null,
private val anonymous: Boolean = true
) : FlowLogic<WireTransaction>() {
companion object {
object INITIALISING : ProgressTracker.Step("Performing initial steps.")
object BUILDING : ProgressTracker.Step("Building and verifying transaction. @@@@@ Testing In CorDapp CreateObligation.kt @@@@@")
object SIGNING : ProgressTracker.Step("signing transaction.")
object COLLECTING : ProgressTracker.Step("Collecting counterparty signature.") {
override fun childProgressTracker() = CollectSignaturesFlow.tracker()
}
object FINALISING : ProgressTracker.Step("Finalising transaction.") {
override fun childProgressTracker() = FinalityFlow.tracker()
}
fun tracker() = ProgressTracker(INITIALISING, BUILDING, SIGNING, COLLECTING, FINALISING)
}
override val progressTracker: ProgressTracker = tracker()
@Suspendable
private fun createAnonymousObligation(): Pair<Obligation<T>, PublicKey> {
val txKeys = subFlow(SwapIdentitiesFlow(counterparty))
// SwapIdentityFlow should return two keys.
check(txKeys.size == 2) { "Something went wrong when generating confidential identities." }
val anonymousMe = txKeys[ourIdentity] ?: throw FlowException("Couldn't create our conf. identity.")
val anonymousObligor = txKeys[counterparty]
?: throw FlowException("Couldn't create lender's conf. identity.")
return createObligation(us = anonymousMe, them = anonymousObligor)
}
private fun createObligation(us: AbstractParty, them: AbstractParty): Pair<Obligation<T>, PublicKey> {
check(us != them) { "You cannot create an obligation to yourself" }
val obligation = when (role) {
InitiatorRole.OBLIGEE -> Obligation(amount, them, us, dueBy)
InitiatorRole.OBLIGOR -> Obligation(amount, us, them, dueBy)
}
return Pair(obligation, us.owningKey)
}
@Suspendable
override fun call(): WireTransaction {
println("!! TESTING - CreateObligation.kt 1.0")
// Step 1. Initialisation.
progressTracker.currentStep = INITIALISING
val (obligation, signingKey) = if (anonymous) {
createAnonymousObligation()
} else {
createObligation(us = ourIdentity, them = counterparty)
}
// Step 2. Check parameters.
if (dueBy != null) {
val todayUTC = LocalDate.now().atStartOfDay().toInstant(ZoneOffset.UTC)
require(dueBy > todayUTC) {
"Due by date must be in the future."
}
}
// Step 3. Building.
progressTracker.currentStep = BUILDING
val notary = serviceHub.networkMapCache.notaryIdentities.firstOrNull()
?: throw FlowException("No available notary.")
val utx = TransactionBuilder(notary = notary).apply {
addOutputState(obligation, ObligationContract.CONTRACT_REF)
val signers = obligation.participants.map { it.owningKey }
addCommand(ObligationCommands.Create(), signers)
setTimeWindow(serviceHub.clock.instant(), 30.seconds)
}
// Step 4. Sign the transaction.
progressTracker.currentStep = SIGNING
val ptx = serviceHub.signInitialTransaction(utx, signingKey)
// Step 5. Get the counterparty signature.
progressTracker.currentStep = COLLECTING
val lenderFlow = initiateFlow(counterparty)
val stx = subFlow(CollectSignaturesFlow(
partiallySignedTx = ptx,
sessionsToCollectFrom = setOf(lenderFlow),
myOptionalKeys = listOf(signingKey),
progressTracker = COLLECTING.childProgressTracker())
)
// Step 6. Finalise and return the transaction.
progressTracker.currentStep = FINALISING
val ntx = subFlow(FinalityFlow(stx, FINALISING.childProgressTracker()))
return ntx.tx
}
}
@InitiatedBy(Initiator::class)
class Responder(val otherFlow: FlowSession) : FlowLogic<WireTransaction>() {
@Suspendable
override fun call(): WireTransaction {
val flow = object : SignTransactionFlow(otherFlow) {
@Suspendable
override fun checkTransaction(stx: SignedTransaction) {
// TODO: Do some basic checking here.
// Reach out to human operator when HCI is available.
}
}
val stx = subFlow(flow)
// Suspend this flow until the transaction is committed.
return waitForLedgerCommit(stx.id).tx
}
}
}
最佳答案
如果我没记错的话,你的流构造函数中不能有默认参数。我相信我们有一个开放的问题可以在某个时候解决它。
关于java - 无法为 com.r3.corda.finance.obligation.flows.CreateObligation$Initiator 类型的 FlowLogic 构造 FlowLogicRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57051035/
我想获取 Yahoo! 中给定交易品种的关键统计数据金融。 我找到了几种使用 Yahoo Finance API 获取统计数据的方法。例如获取Apple的名称(n),ask(a),bid(b),mar
我如何通过 C# 接收股票报价? Google Finance API 不是很有用 最佳答案 Google Finance API Alternative。Google Finance API 的免费
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我尝试按照 read.csv("http://ichart.finance.yahoo.com/table.csv?s=SPY") Not Working 的建议同时使用 http 和 https .
在过去的 3 年中,我一直在使用以下 URL,没有出现任何问题。但是,它已停止返回结果。 网址: https://query.yahooapis.com/v1/public/yql?q=select
我要求资深金融程序员提供最佳实践。 例如 PSUDO 代码: class Transaction(Model): order = ForeignKey() amount = Decim
我在一家专门从事金融的精品店工作。 我们考虑设计一种语言来描述与金融市场相关的金融实体。 这将主要用作某种脚本语言来替换在电子表格和 VBA 宏中运行的许多进程。 它必须很简单,事实上,它必须在幕后调
OrderBook充满了买卖订单。更新,新订单可能会执行交易。 我似乎找不到任何实现的示例。 我们可以为每个订单指定一个ID,并一一检查执行订单。但是我们想要可以扩展到数千个有效订单的产品。 我们可以
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
通过盈透证券的 API 方法 tickPrice 或 tickSize 接收金融报价数据时,数据将具有以下参数 tickerId(符号) 字段(1=买价、2=卖价、4=最后价、6=最高价、7=最低价、
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我正在编写一些用于股权的机器学习软件,并且希望找到一些即时数据或至少 3 或 5 分钟的数据。 我想要一两年的时间进行测试。 我并不关心数据来自哪个交易所,只要它来自某处的主要交易所即可。 还有什么地
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我是 QuickFix 的新手,我有几个关于 QuickFix 库的问题,我将非常乐意从您那里得到答案: 我计划开发 FIX 服务器,它可以同时从多个客户端获取 FIX 请求。对此, a) 如果我需要
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
只是想知道那里有什么样的免费金融 API。我正在寻找可以指定索引并通过股票代码获取该索引中包含的所有公司的列表的东西。 目前我只对在纽约证券交易所上市的公司股票感兴趣。我真的很感激任何关于 API 或
看起来应该是个简单的问题。我正在使用 Matlab 构建股票数据库和分析工具包。 我正在使用 Matlab 函数获取数据表,使用如下 URL: http://ichart.finance.yahoo.
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 去年关闭。 Improve this
我是一名优秀的程序员,十分优秀!