【问题标题】:Corda: Synchronize multiple Nodes that represent same PartyCorda:同步代表同一方的多个节点
【发布时间】:2020-06-02 21:14:55
【问题描述】:

我正在开发一个包含多个节点的 Cordapp。在我的应用程序中,每一方都将由运行在不同位置的两个节点代表。其中一个节点将始终在线,而另一个节点有时可能离线/在线。

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

您能否建议您是否遇到过类似的场景,并且这里已经有任何可用的 API/用例。

【问题讨论】:

  • 场景:在流的广播步骤中,如果对方离线,它会无限等待。我们可以将其作为一个异步过程来执行,其中广播可以启动发送状态/事务并在当前节点中提交事务。另一方可以在它上线时收到状态。
  • 听起来像是故障转移/HA 方案。不要认为corda还处于那个阶段。请参阅 Corda HA/故障转移的设计规范:discourse.corda.net/t/…

标签: corda


【解决方案1】:

您可以为开/关节点编写一对流,以请求从始终在线节点克隆所有详细信息。

开/关节点

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 是我写的一个例子,股东向公司询问任何有关 StockState 的交易。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多