Reputation: 43
I need an object to be distributed around 3 nodes on my network
So i have 2 flows, A sends Data to B and ledger is updated. i then want a flow to "forward" the same data on to another node, B sends Data to C.
if i copy the object then i have 2 entries of the data in my vault:
// get data from my query (assume only one piece of data)
val queryResults: Vault.Page<DataState> = serviceHub.vaultService.queryBy(query)
val states: List<StateAndRef<DataState>> = results.states
// We create a transaction builder and add the components.
val txBuilder = TransactionBuilder(notary = notary)
// Loop our chunks
for (dataState in states) {
val data = dataState.state.data.copy(participants = listOf(ourIdentity, otherParty))
txBuilder.addOutputState(data)
}
// Add the command to the transaction.
val command = Command(DataContract.Commands.Action(), ourIdentity.owningKey)
txBuilder.addCommand(command)
// We sign the transaction.
val signedTx: SignedTransaction = serviceHub.signInitialTransaction(txBuilder)
// We finalise the transaction and then send.
subFlow(FinalityFlow(signedTx, otherPartySession))
How do i "forward" it on in a new flow without duplication? and BTW A wont be available when I send between B and C
Im guessing this is definitely wrong because its not initial:
val signedTx: SignedTransaction = serviceHub.signInitialTransaction(txBuilder)
Upvotes: 0
Views: 129
Reputation: 2548
You can use the SendStateAndRefFlow
(the counter-party nodes must call ReceiveStateAndRefFlow
in a responder flow):
SendStateAndRefFlow(otherSideSession: FlowSession, stateAndRefs: List<StateAndRef<*>>)
Upvotes: 1