Corda 试图通过流将状态对象发送到另一个节点
我需要一个对象分布在我的网络上的3个节点周围 所以我有两个流程,A向B发送数据,并且更新分类账。然后我想要一个流将相同的数据“转发”到另一个节点,B将数据发送到C 如果复制对象,则vault中有2个数据条目:Corda 试图通过流将状态对象发送到另一个节点,corda,Corda,我需要一个对象分布在我的网络上的3个节点周围 所以我有两个流程,A向B发送数据,并且更新分类账。然后我想要一个流将相同的数据“转发”到另一个节点,B将数据发送到C 如果复制对象,则vault中有2个数据条目: // get data from my query (assume only one piece of data) val queryResults: Vault.Page<DataState> = serviceHub.vaultService.queryBy
// 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))
//从我的查询中获取数据(假设只有一条数据)
val queryResults:Vault.Page=serviceHub.vaultService.queryBy(查询)
val状态:列表=结果。状态
//我们创建一个事务生成器并添加组件。
val txBuilder=TransactionBuilder(公证人=公证人)
//循环我们的区块
for(数据状态在状态中){
val data=dataState.state.data.copy(参与者=listOf(ourIdentity,otherParty))
txBuilder.addOutputState(数据)
}
//将命令添加到事务中。
val command=command(DataContract.Commands.Action(),ourIdentity.owningKey)
txBuilder.addCommand(命令)
//我们在交易上签字。
val signedTx:SignedTransaction=serviceHub.signInitialTransaction(txBuilder)
//我们完成交易,然后发送。
子流(最终流(签名的X,其他方会话))
如何在新流程中“转发”它而不重复?
顺便说一句,当我在B和C之间发送时,A将不可用
我猜这肯定是错误的,因为它不是首字母:
val signedTx:SignedTransaction=serviceHub.signInitialTransaction(txBuilder)
您可以使用sendstate和fflow
(对方节点必须在响应程序流中调用receivestate和fflow
):
SendStateAndRefLow(otherSideSession:FlowSession,stateAndRefs:List)
您能解释一下您的用例吗?为什么不能与所有3个节点共享单个事务中的状态?节点C在a到B事务期间或从a到B的流程期间不可用。这很好,但是我希望从B到C的事务是一个账本更新并持久化。此外,我还得到了一个“试图使用空缓冲区访问已结束的会话SessionId(toLong=-{ID})”,然后您可以使用SendTransactionFlow(另一端:FlowSession,stx:SignedTransaction)
,您的响应者节点必须调用ReceiveTransactionFlow
。如何将我的TransactionState重新放入已签名的Transaction中?当响应节点调用ReceiveTransactionFlow
时,它应该使用参数StatesToRecord=StatesToRecord.ALL
调用它;这样,节点将注册事务和该事务中的所有状态。默认值为StatesToRecord=StatesToRecord.NONE
,这意味着只注册事务(和NONE
状态)。