Warm tip: This article is reproduced from serverfault.com, please click

Corda Flow Responder counter party logic

发布于 2020-12-20 23:50:52

Basically, i have initiating flow with state producing transaction, involving 3 parties:

PartyA - ourIdentity
PartyB - should sign
PartyC - should sign

Initiating flow creates new state and builds transaction, then collects signatures from other parties.

PartyB and PartyC should make own specific business logic verification.
Will it be correct to place those checks in flow responder, if not - where to place them?
Also, can i separate responder code like:

override fun call(): SignedTransaction {
    val signTransactionFlow = object : SignTransactionFlow(otherPartySession) {
        override fun checkTransaction(stx: SignedTransaction) = requireThat {
            val output = stx.tx.outputs.single().data
            
            if (otherPartySession.counterParty == output.participantB) {
               // Do checks for PartyB
            }
            
            if (otherPartySession.counterParty == output.participantC) {
               // Do checks for PartyC
            }
        }
    }
    val txId = subFlow(signTransactionFlow).id

    return subFlow(ReceiveFinalityFlow(otherPartySession, expectedTxId = txId))
}
Questioner
johnbrovi
Viewed
1
Alessandro Baffa 2020-12-21 09:40:36

Yes, the transaction verification by PartyB and PartyC should be placed in the Responder flow. The solution you propose is correct. More commonly, the Responder flow can also be split in different nodes, one in PartyB's node and one in PartyC's, so that they do not see each other's implementation.