CORDA:对交易中涉及的所有各方调用自定义查询

CORDA: Invoke custom query on all parties involved in transaction

我有多个关于 Corda 的问题:

  1. 我们可以预定义 h2 配置以在 build.gradle 文件中选择吗?
  2. 我的 corda 网络中有一笔交易,我想根据 custom fields 验证某些内容,验证必须根据需要在所有 3 方上触发的查询进行 sender, receiver, notary 我如何获取所有 3 个节点的会话?我可以使用 getServiceHub().jdbcSession()
  3. 拉取 sender 的会话
  4. 查询自定义字段的公证人最推荐的方法是什么?是否可以使用创建子流程来完成,如果是,那么如何?
  5. 我们有验证和非验证公证人,我们实际在哪里使用公证人进行验证?我们在哪里写验证码?
  6. 我们如何在 intellij 中为 corda 的 java api 启用自动提示?
  1. 您可以在deployNodes中设置h2Port选项:

    node {
        name "O=PartyA,L=London,C=GB"
        advertisedServices = []
        p2pPort 10005
        rpcPort 10006
        webPort 10007
        h2Port 10008
        cordapps = ["net.corda:corda-finance:$corda_release_version"]
        rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
    }
    

    这是您需要的配置吗?

  2. 每个节点的数据库在设计上都是私有的,不能从另一个节点查询。相反,您需要在流程中与其他节点进行通信,使它们在自己的端启动响应流,查询自己的数据库并将结果发回。类似于:

    public class CollectDBDataFlow {
    @InitiatingFlow
    @StartableByRPC
    public static class Initiator extends FlowLogic<List<Object>> {
        Party counterparty;
    
        public Initiator(Party counterparty) {
            this.counterparty = counterparty;
        }
    
        @Suspendable
        @Override public List<Object> call() {
            // TODO: Implement queryMyDatabase to perform querying.
            Object myDBData = queryMyDatabase();
    
            FlowSession counterpartySession = initiateFlow(counterparty);
            Object theirDBData = counterpartySession.receive(Object.class);
    
            return ImmutableList.of(myDBData, theirDBData);
        }
    }
    
    @InitiatedBy(Initiator.class)
    public static class Responder extends FlowLogic<Void> {
        private FlowSession counterpartySession;
    
        public Responder(FlowSession counterpartySession) {
            this.counterpartySession = counterpartySession;
        }
    
        @Suspendable
        @Override
        public Void call() {
            // TODO: Implement queryMyDatabase to perform querying.
            Object myDBData = queryMyDatabase();
    
            counterpartySession.send(myDBData);
    
            return null;
        }
    }
    }
    
  3. 公证人的作用不是查询数据,而是防止双花。从技术上讲,您可以使用上面 (2) 中描述的方法来执行此操作,但不建议这样做。你想达到什么目的?

  4. 验证逻辑已写入平台。见 https://github.com/corda/corda/blob/release-V1/node/src/main/kotlin/net/corda/node/services/transactions/ValidatingNotaryFlow.kt.

  5. 自动完成应该会自动出现,就像任何其他库一样。