Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Require explanation for the responder flows #2

Open
waynelcw opened this issue Nov 29, 2019 · 0 comments
Open

Require explanation for the responder flows #2

waynelcw opened this issue Nov 29, 2019 · 0 comments

Comments

@waynelcw
Copy link

waynelcw commented Nov 29, 2019

The following lines can be seen in many other flows.
But it is hard to follow by just viewing the code.

val accountMovedTo = AtomicReference<AccountInfo>()
//extract account information from transaction
val transactionSigner = object : SignTransactionFlow(counterpartySession) {
override fun checkTransaction(tx: SignedTransaction) {
val keyStateMovedTo = tx.coreTransaction.outRefsOfType(InvoiceState::class.java).first().state.data.recipient
keyStateMovedTo?.let {
accountMovedTo.set(accountService.accountInfo(keyStateMovedTo.owningKey)?.state?.data)
}
if (accountMovedTo.get() == null) {
throw IllegalStateException("Account to move to was not found on this node")
}
}
}
//record and finalize transaction
val transaction = subFlow(transactionSigner)
if (counterpartySession.counterparty != serviceHub.myInfo.legalIdentities.first()) {
val recievedTx = subFlow(ReceiveFinalityFlow(counterpartySession, expectedTxId = transaction.id, statesToRecord = StatesToRecord.ALL_VISIBLE))
val accountInfo = accountMovedTo.get()
if (accountInfo != null) {
subFlow(BroadcastToCarbonCopyReceiversFlow(accountInfo, recievedTx.coreTransaction.outRefsOfType(InvoiceState::class.java).first()))
}
}
}

@waynelcw waynelcw changed the title Require detailed explanation for responder flows Require explanation for responder flows Nov 29, 2019
@waynelcw waynelcw changed the title Require explanation for responder flows Require explanation for the responder flows Nov 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant