Reputation: 105
I used the below flow to share the account from one Node to Other Node
@InitiatingFlow
@StartableByService
@StartableByRPC
class ShareAccountInfotoOtherParty(val accountName: String,
val partyName: String) : FlowLogic<String>() {
@Suspendable
override fun call(): String {
val TestAccount = subFlow(OurAccounts()).filter { it.state.data.name == accountName }.last()
val newParty = serviceHub.identityService.partiesFromName(partyName,exactMatch = true).last()
val session1 = initiateFlow(newParty)
val a = ShareAccountInfoFlow(TestAccount, listOf(session1))
return "sharing Done ${a}"
}
@InitiatedBy(ShareAccountInfotoOtherParty::class)
class ShareAccountInfoHandlerFlow(val otherSession: FlowSession) : FlowLogic<AccountInfo>() {
@Suspendable
override fun call(): AccountInfo {
val transaction = subFlow(ReceiveTransactionFlow(
otherSideSession = otherSession,
statesToRecord = StatesToRecord.ALL_VISIBLE
))
return transaction.coreTransaction.outputsOfType(AccountInfo::class.java).single()
}
}
}
The flow is not throwing any error but the table of receiver Node(Accounts Table) is not getting any update.
Upvotes: 0
Views: 259
Reputation: 2548
inline
version of the flow (i.e. the pair ShareAccountInfoFlow
and ShareAccountInfoHandlerFlow
). Instead, use the initiating
version (i.e. ShareAccountInfo
) which doesn't require having a responder flow. inline
version if your flow is a pair (initiator and responder) where you require some action/validation in the responder (i.e. node receiving the account info) before it actually receives it (i.e. before it calls the library's ShareAccountInfoHandlerFlow
). ShareAccountInfo
flow tests: https://github.com/corda/accounts/blob/master/workflows/src/test/kotlin/com/r3/corda/lib/accounts/workflows/test/ShareAccountFlowTests.ktUpvotes: 1