2017-10-18 9 views
0

私は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": []]] 
} 
+0

APIコールを送信できますか?上で定義されていない 'InitiatorFlow'を開始しているようです。 – joel

+0

申し訳ありません。 API呼び出しと正しいフローエラーで質問を更新しました。 – codeviper

+0

どのようにノードを実行してAPIをテストしていますか? – joel

答えて

0

あなたが投稿したコードに問題のカップルがあるように表示されます。

  • 注釈がなければなりません@StartableByRPCではなく、@StartableNByRPC
  • startTrackedFlowに渡される価格は、intでなくlongでなければなりません

しかし、これらの問題を修正しても、私はあなたのエラーを再現することができませんでした。これらの修正を適用し、ノードのクリーンな再デプロイメント(gradlew clean deployNodes)を行い、エラーが変更されているかどうか確認できますか?

+0

ありがとう問題に私は修正を加え、deployNodesをきれいにしました。しかし、私は同じエラーを参照してください。 deployNodesタスクで権限の一部としてノードを追加する必要はありますか?または私は他のステップを逃していますか? – codeviper

+0

質問内のコードサンプルを更新して、エラーを修正し、APIで相手方を取得する方法を示すことはできますか? – joel

+0

コードサンプルを修正し、他のPartyを取得するコードを追加しました。 – codeviper

0

RPC経由で他のノードに接続しないでください。 RPCは、ノードの所有者がノードに対してどのように話すかを示します。現実の世界では、他のノードのRPC資格情報を持たず、この方法でノードにログインできませんでした。

代わりに、あなたは相手の身元を取得するために、独自のノードのRPCクライアントを使用する必要があります。https://github.com/corda/cordapp-example/blob/release-M14/kotlin-source/src/main/kotlin/com/example/api/ExampleApi.kt

val otherParty = services.partyFromX500Name("CN=Other,O=Other,L=NY,C=US")!!

ここでM14の例を参照してください。

+0

意味があります。ありがとう。 – codeviper

関連する問題