mirror of
https://github.com/corda/corda.git
synced 2025-02-06 11:09:18 +00:00
Fix tut-two-party-flow kotlin docs + make both versions easier to read (#5024)
- `DOCSTART`s were not in sync - Incorrect indentation - Documentation not very clear
This commit is contained in:
parent
855d1323a4
commit
360660e4d7
@ -18,10 +18,10 @@ public class IOUFlowResponder extends FlowLogic<Void> {
|
|||||||
this.otherPartySession = otherPartySession;
|
this.otherPartySession = otherPartySession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DOCSTART 1
|
||||||
@Suspendable
|
@Suspendable
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws FlowException {
|
public Void call() throws FlowException {
|
||||||
// DOCSTART 01
|
|
||||||
class SignTxFlow extends SignTransactionFlow {
|
class SignTxFlow extends SignTransactionFlow {
|
||||||
private SignTxFlow(FlowSession otherPartySession) {
|
private SignTxFlow(FlowSession otherPartySession) {
|
||||||
super(otherPartySession);
|
super(otherPartySession);
|
||||||
@ -44,6 +44,6 @@ public class IOUFlowResponder extends FlowLogic<Void> {
|
|||||||
subFlow(new ReceiveFinalityFlow(otherPartySession, expectedTxId));
|
subFlow(new ReceiveFinalityFlow(otherPartySession, expectedTxId));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
// DOCEND 01
|
|
||||||
}
|
}
|
||||||
|
// DOCEND 1
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import net.corda.core.flows.*
|
|||||||
import net.corda.docs.kotlin.tutorial.helloworld.IOUFlow
|
import net.corda.docs.kotlin.tutorial.helloworld.IOUFlow
|
||||||
import net.corda.docs.kotlin.tutorial.helloworld.IOUState
|
import net.corda.docs.kotlin.tutorial.helloworld.IOUState
|
||||||
|
|
||||||
// DOCSTART 01
|
|
||||||
// Add these imports:
|
// Add these imports:
|
||||||
import net.corda.core.contracts.requireThat
|
import net.corda.core.contracts.requireThat
|
||||||
import net.corda.core.transactions.SignedTransaction
|
import net.corda.core.transactions.SignedTransaction
|
||||||
@ -15,9 +14,9 @@ import net.corda.core.transactions.SignedTransaction
|
|||||||
// Define IOUFlowResponder:
|
// Define IOUFlowResponder:
|
||||||
@InitiatedBy(IOUFlow::class)
|
@InitiatedBy(IOUFlow::class)
|
||||||
class IOUFlowResponder(val otherPartySession: FlowSession) : FlowLogic<Unit>() {
|
class IOUFlowResponder(val otherPartySession: FlowSession) : FlowLogic<Unit>() {
|
||||||
|
// DOCSTART 1
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call() {
|
override fun call() {
|
||||||
// DOCSTART 01
|
|
||||||
val signTransactionFlow = object : SignTransactionFlow(otherPartySession) {
|
val signTransactionFlow = object : SignTransactionFlow(otherPartySession) {
|
||||||
override fun checkTransaction(stx: SignedTransaction) = requireThat {
|
override fun checkTransaction(stx: SignedTransaction) = requireThat {
|
||||||
val output = stx.tx.outputs.single().data
|
val output = stx.tx.outputs.single().data
|
||||||
@ -28,6 +27,6 @@ class IOUFlowResponder(val otherPartySession: FlowSession) : FlowLogic<Unit>() {
|
|||||||
}
|
}
|
||||||
val expectedTxId = subFlow(signTransactionFlow).id
|
val expectedTxId = subFlow(signTransactionFlow).id
|
||||||
subFlow(ReceiveFinalityFlow(otherPartySession, expectedTxId))
|
subFlow(ReceiveFinalityFlow(otherPartySession, expectedTxId))
|
||||||
// DOCEND 01
|
|
||||||
}
|
}
|
||||||
|
// DOCEND 1
|
||||||
}
|
}
|
||||||
|
@ -87,14 +87,15 @@ to respond, we need to update its responder flow to first receive the partially
|
|||||||
|
|
||||||
.. literalinclude:: example-code/src/main/kotlin/net/corda/docs/kotlin/tutorial/twoparty/IOUFlowResponder.kt
|
.. literalinclude:: example-code/src/main/kotlin/net/corda/docs/kotlin/tutorial/twoparty/IOUFlowResponder.kt
|
||||||
:language: kotlin
|
:language: kotlin
|
||||||
:start-after: DOCSTART 01
|
:start-after: DOCSTART 1
|
||||||
:end-before: DOCEND 01
|
:end-before: DOCEND 1
|
||||||
|
:dedent: 4
|
||||||
|
|
||||||
.. literalinclude:: example-code/src/main/java/net/corda/docs/java/tutorial/twoparty/IOUFlowResponder.java
|
.. literalinclude:: example-code/src/main/java/net/corda/docs/java/tutorial/twoparty/IOUFlowResponder.java
|
||||||
:language: java
|
:language: java
|
||||||
:start-after: DOCSTART 01
|
:start-after: DOCSTART 1
|
||||||
:end-before: DOCEND 01
|
:end-before: DOCEND 1
|
||||||
:dedent: 8
|
:dedent: 4
|
||||||
|
|
||||||
We could write our own flow to handle this process. However, there is also a pre-defined flow called
|
We could write our own flow to handle this process. However, there is also a pre-defined flow called
|
||||||
``SignTransactionFlow`` that can handle the process automatically. The only catch is that ``SignTransactionFlow`` is an
|
``SignTransactionFlow`` that can handle the process automatically. The only catch is that ``SignTransactionFlow`` is an
|
||||||
|
Loading…
x
Reference in New Issue
Block a user