From a78278927fea6aff97ee9018c408e0bdef8b54e8 Mon Sep 17 00:00:00 2001 From: rogersanick Date: Tue, 8 Jan 2019 16:29:59 -0500 Subject: [PATCH] Updating FinalityFlow documentation with example code for use with SignTransactionFlow in flow responder. --- .../java/net/corda/docs/java/FinalityFlowMigration.java | 9 ++++++--- .../net/corda/docs/kotlin/FinalityFlowMigration.kt | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/source/example-code/src/main/java/net/corda/docs/java/FinalityFlowMigration.java b/docs/source/example-code/src/main/java/net/corda/docs/java/FinalityFlowMigration.java index ddb38ebd0b..2923792ec3 100644 --- a/docs/source/example-code/src/main/java/net/corda/docs/java/FinalityFlowMigration.java +++ b/docs/source/example-code/src/main/java/net/corda/docs/java/FinalityFlowMigration.java @@ -110,18 +110,21 @@ public class FinalityFlowMigration { @Suspendable @Override public Void call() throws FlowException { + + // DOCSTART ExistingResponderFlow + // First we have to run the SignTransactionFlow, which will return a SignedTransaction. SignedTransaction txWeJustSigned = subFlow(new SignTransactionFlow(otherSide) { @Suspendable @Override protected void checkTransaction(@NotNull SignedTransaction stx) throws FlowException { - // Do checks here + // Implement responder flow transaction checks here } }); - // DOCSTART ExistingResponderFlow + if (otherSide.getCounterpartyFlowInfo().getFlowVersion() >= 2) { // The other side is not using the old CorDapp so call ReceiveFinalityFlow to record the finalised transaction. // If SignTransactionFlow is used then we can verify the tranaction we receive for recording is the same one - // that was just signed. + // that was just signed by passing the transaction id to ReceiveFinalityFlow. subFlow(new ReceiveFinalityFlow(otherSide, txWeJustSigned.getId())); } else { // Otherwise the other side is running the old CorDapp and so we don't need to do anything further. The node diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/kotlin/FinalityFlowMigration.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/kotlin/FinalityFlowMigration.kt index 493105a875..64f52fc38e 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/kotlin/FinalityFlowMigration.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/kotlin/FinalityFlowMigration.kt @@ -70,13 +70,15 @@ class ExistingInitiatingFlow(private val counterparty: Party) : FlowLogic() { @Suspendable override fun call() { + // DOCSTART ExistingResponderFlow + // First we have to run the SignTransactionFlow, which will return a SignedTransaction. val txWeJustSigned = subFlow(object : SignTransactionFlow(otherSide) { @Suspendable override fun checkTransaction(stx: SignedTransaction) { - // Do checks here + // Implement responder flow transaction checks here } }) - // DOCSTART ExistingResponderFlow + if (otherSide.getCounterpartyFlowInfo().flowVersion >= 2) { // The other side is not using the old CorDapp so call ReceiveFinalityFlow to record the finalised transaction. // If SignTransactionFlow is used then we can verify the tranaction we receive for recording is the same one