私はM14を使用して2PartyProtocolを実行してデータ有効性コンセンサスに達するようにデータを交換できるコードを作成して実行するCordaアプリケーションを使用しました。私はフローを構築するためにCorda flow cookbookに従った。Corda:リクエスタが登録されていないため、パーティーが拒否したセッションリクエスト
また、いくつかの異なるコードマイルストーンからドキュメントを読んだ後で、M14はもはやサービスを登録する必要性を排除するrelease notesで言及されたフローセッションを必要としないことを理解しました。
マイインナーFlowLogicsとTwoPartyFlow:APIからstartTrackedFlowを使用して上記を実行している
class TwoPartyFlow{
@InitiatingFlow
@StartableByRPC
open class Requestor(val price: Long,
val otherParty: Party) : FlowLogic<SignedTransaction>(){
@Suspendable
override fun call(): SignedTransaction {
val notary = serviceHub.networkMapCache.notaryNodes.single().notaryIdentity
send(otherParty, price)
/*Some code to generate SignedTransaction*/
}
}
@InitiatedBy(Requestor::class)
open class Responder(val requestingParty : Party) : FlowLogic<SignedTransaction>(){
@Suspendable
override fun call(): SignedTransaction {
val request = receive<Long>(requestor).unwrap { price -> price }
println(request)
/*Some code to generate SignedTransaction*/
}
}
}
しかしが、上記のエラーが発生します。
Party CN=Other,O=Other,L=NY,C=US rejected session request: com.testapp.flow.TwoPartyFlow$Requestor has not been registered
私はコルダドキュメントまたはログから理由を見つけるのに苦労していた
2パーティフローの実装がいくつかのマイルストーン間で変更されているためです。誰かがここで問題を理解するのを助けることができますか?
私のAPIコール:
@GET
@Path("start-flow")
fun requestOffering(@QueryParam(value = "price") price: String) : Response{
val price : Long = 10L
/*Code to get otherParty details*/
val otherPartyHostAndPort = HostAndPort.fromString("localhost:10031")
val client = CordaRPCClient(otherPartyHostAndPort)
val services : CordaRPCOps = client.start("user1","test").proxy
val otherParty: Party = services.nodeIdentity().legalIdentity
val (status, message) = try {
val flowHandle = services.startTrackedFlow(::Requestor, price, otherParty)
val result = flowHandle.use { it.returnValue.getOrThrow() }
// Return the response.
Response.Status.CREATED to "Transaction id ${result.id} committed to ledger.\n"
} catch (e: Exception) {
Response.Status.BAD_REQUEST to e.message
}
return Response.status(status).entity(message).build()
}
私のGradle deployNodesタスク:
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['build']) {
directory "./build/nodes"
networkMap "CN=Controller,O=R3,OU=corda,L=London,C=UK"
node {
name "CN=Controller,O=R3,OU=corda,L=London,C=UK"
advertisedServices = ["corda.notary.validating"]
p2pPort 10021
rpcPort 10022
cordapps = []
}
node {
name "CN=Subject,O=Subject,L=NY,C=US"
advertisedServices = []
p2pPort 10027
rpcPort 10028
webPort 10029
cordapps = []
rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
}
node {
name "CN=Other,O=Other,L=NY,C=US"
advertisedServices = []
p2pPort 10030
rpcPort 10031
webPort 10032
cordapps = []
rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
}
APIコールを送信できますか?上で定義されていない 'InitiatorFlow'を開始しているようです。 – joel
申し訳ありません。 API呼び出しと正しいフローエラーで質問を更新しました。 – codeviper
どのようにノードを実行してAPIをテストしていますか? – joel