Updating FinalityFlow documentation with example code for use with SignTransactionFlow in flow responder.

This commit is contained in:
rogersanick 2019-01-08 16:29:59 -05:00
parent d33cb16c5e
commit a78278927f
2 changed files with 10 additions and 5 deletions

View File

@ -110,18 +110,21 @@ public class FinalityFlowMigration {
@Suspendable @Suspendable
@Override @Override
public Void call() throws FlowException { 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) { SignedTransaction txWeJustSigned = subFlow(new SignTransactionFlow(otherSide) {
@Suspendable @Suspendable
@Override @Override
protected void checkTransaction(@NotNull SignedTransaction stx) throws FlowException { protected void checkTransaction(@NotNull SignedTransaction stx) throws FlowException {
// Do checks here // Implement responder flow transaction checks here
} }
}); });
// DOCSTART ExistingResponderFlow
if (otherSide.getCounterpartyFlowInfo().getFlowVersion() >= 2) { if (otherSide.getCounterpartyFlowInfo().getFlowVersion() >= 2) {
// The other side is not using the old CorDapp so call ReceiveFinalityFlow to record the finalised transaction. // 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 // 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())); subFlow(new ReceiveFinalityFlow(otherSide, txWeJustSigned.getId()));
} else { } else {
// Otherwise the other side is running the old CorDapp and so we don't need to do anything further. The node // Otherwise the other side is running the old CorDapp and so we don't need to do anything further. The node

View File

@ -70,13 +70,15 @@ class ExistingInitiatingFlow(private val counterparty: Party) : FlowLogic<Signed
class ExistingResponderFlow(private val otherSide: FlowSession) : FlowLogic<Unit>() { class ExistingResponderFlow(private val otherSide: FlowSession) : FlowLogic<Unit>() {
@Suspendable @Suspendable
override fun call() { override fun call() {
// DOCSTART ExistingResponderFlow
// First we have to run the SignTransactionFlow, which will return a SignedTransaction.
val txWeJustSigned = subFlow(object : SignTransactionFlow(otherSide) { val txWeJustSigned = subFlow(object : SignTransactionFlow(otherSide) {
@Suspendable @Suspendable
override fun checkTransaction(stx: SignedTransaction) { override fun checkTransaction(stx: SignedTransaction) {
// Do checks here // Implement responder flow transaction checks here
} }
}) })
// DOCSTART ExistingResponderFlow
if (otherSide.getCounterpartyFlowInfo().flowVersion >= 2) { if (otherSide.getCounterpartyFlowInfo().flowVersion >= 2) {
// The other side is not using the old CorDapp so call ReceiveFinalityFlow to record the finalised transaction. // 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 // If SignTransactionFlow is used then we can verify the tranaction we receive for recording is the same one