试图通过流程将一个状态对象发送到另一个节点上。

问题描述 投票:0回答:1

我需要一个对象分布在我的网络中的3个节点上。

所以我有2个流,A发送数据给B,分类账被更新。然后我想让一个流把同样的数据 "转发 "到另一个节点,B发送数据给C。

如果我复制对象,那么我的保险库中就有两个数据条目。

    // 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))

我如何在一个新的流程中 "转发 "它而不重复? 另外,当我在B和C之间发送数据时,A是不可用的。

我猜这绝对是错误的,因为它不是初始化的。

val signedTx: SignedTransaction = serviceHub.signInitialTransaction(txBuilder)

corda
1个回答
1
投票

你可以使用 SendStateAndRefFlow (对方节点必须调用 ReceiveStateAndRefFlow 响应者流程中)。)

SendStateAndRefFlow(otherSideSession: FlowSession, stateAndRefs: List<StateAndRef<*>>)
© www.soinside.com 2019 - 2024. All rights reserved.