Reputation:
How does the counterparty flow (for example, the buyer in the TwoPartyTradeFlow) receive parameters? The documentation does not explain this very clear to me.
So far it seems to me that in the TwoPartyTradeFlow, the Seller is passed the other party flow session, although you can also initialize this yourself using initiateFlow(party)
. In the other examples I have seen, the counterparty receives the initiator's flow session. However, in this code snippet, the buyer receives additional parameters such as notary, price, etc. How are these passed in?
open class Buyer(private val sellerSession: FlowSession,
private val notary: Party,
private val acceptablePrice: Amount<Currency>,
private val typeToBuy: Class<out OwnableState>,
private val anonymous: Boolean) : FlowLogic<SignedTransaction>() {
@Suspendable
override fun call(): SignedTransaction {
TODO()
}
}
This code has been taken from the first code snippet here. https://docs.corda.net/head/flow-state-machines.html
Upvotes: 0
Views: 65
Reputation: 444
The TwoPartyTradeFlow.Seller
and TwoPartyTradeFlow.Buyer
are inlined flows. The actual flows that call them are
Initiating SellerFlow
here
InitiatedBy BuyerFlow
here
The SellerFlow
will preemptively send some payload to the buyer where the BuyerFlow
being a responder will receive them and then subflow the TwoPartyTradeFlow.Buyer(...)
with the given params.
Helpful link on how inline flows work here
Upvotes: 1