Corda:同步代表同一参与方的多个节点 [英] Corda: Synchronize multiple Nodes that represent same Party

查看:62
本文介绍了Corda:同步代表同一参与方的多个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究包含多个节点的Cordapp.在我的应用中,每一方都将由在不同位置运行的两个节点表示.其中一个节点将始终处于在线"状态,而另一个节点有时可以处于脱机/在线状态.

I am working on a Cordapp that contain multiple nodes. In my app, every party will be represented by two nodes running at different locations. One of the nodes will always be Online where as the other node can be offline/online at times.

我正在寻找一个内置Corda的API,它将使离线节点能够运行作业/api以与在线节点同步.我找不到任何这样的API.

I am looking for an API with-in Corda that will enable the offline node to run a job/api to synchronize with the online node. I could not find any such API.

请问您是否遇到过类似情况,并且这里已经是任何可用的API/用例.

Can you please suggest if you have come across a similar scenario and it here is already any available API/usecase.

推荐答案

您可以为on/off节点编写一对流程,以请求从Always-online节点克隆所有详细信息.

You can write a pair of flows for the on/off node to request clone all the details from the always-online node.

开/关节点

FlowSession session = initiateFlow(alwaysOnNode);

//Send any hint for the other node to query the past transactions, maybe a timestamp?
session.send(hint);

/*
* Waiting for the On/Off node to reply
*/

//Receive the transaction and store it in its vault. The use of ALL_VISIBLE is critical here
subFlow(new ReceiveTransactionFlow(session, true, StatesToRecord.ALL_VISIBLE));

始终在节点上

//Query the newest transaction happened from the vault. Here I used the transaction hash in my case
SignedTransaction stx = getServiceHub().getValidatedTransactions().getTransaction(state.getRef().getTxhash());

//Send it back to the on/off node for update
subFlow(new SendTransactionFlow(holderSession, stx));

Here is an example I wrote which the shareholder asks the company for any happened transaction about a StockState.

这篇关于Corda:同步代表同一参与方的多个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆