【问题标题】:Is it possible to add an auditor peer in corda?是否可以在 corda 中添加审核员同行?
【发布时间】:2018-11-20 00:16:23
【问题描述】:

我想在 corda 中添加某种审计同行。我的用例可以吗?:

目前网络有两个对等点:partyA 和partyB。大约有 100 笔交易涉及双方。让我们稍后再说说,当 C 方(审计员)加入网络时:是否可以让 C 方访问涉及 A 方和 B 方的账本中所有已发布(和未来)的交易?

【问题讨论】:

    标签: corda


    【解决方案1】:

    您应该使用观察者节点功能。请参阅教程 here 和 Observable States 示例 here

    在您的情况下,当审计员首次加入网络时,您需要 partyApartyB 的以下流将所有过去的交易发送给审计员:

    @InitiatingFlow
    @StartableByRPC
    class SendAllPastTransactionsToAuditor : FlowLogic<Unit>() {
        @Suspendable
        override fun call() {
            // We extract all existing transactions from the vault.
            val transactionFeed = serviceHub.validatedTransactions.track()
            transactionFeed.updates.notUsed()
            val transactions = transactionFeed.snapshot
    
            // We send all the existing transactions to the auditor.
            val auditor = serviceHub.identityService.partiesFromName("Auditor", true).single()
            val session = initiateFlow(auditor)
            transactions.forEach { transaction ->
                subFlow(SendToAuditorFlow(session, transaction))
            }
        }
    }
    
    @InitiatingFlow
    class SendToAuditorFlow(val session: FlowSession, val transaction: SignedTransaction) : FlowLogic<Unit>() {
        @Suspendable
        override fun call() {
            subFlow(SendTransactionFlow(session, transaction))
        }
    }
    
    @InitiatedBy(SendToAuditorFlow::class)
    class ReceiveAsAuditorFlow(private val otherSideSession: FlowSession) : FlowLogic<Unit>() {
        @Suspendable
        override fun call() {
            // We record all the visible states in the transactions we receive.
            subFlow(ReceiveTransactionFlow(otherSideSession, true, StatesToRecord.ALL_VISIBLE))
        }
    }
    

    那么对于partyApartyB之间的所有后续交易,您需要执行以下操作通知审计员:

    @InitiatingFlow
    @StartableByRPC
    class RegularFlow : FlowLogic<Unit>() {
        @Suspendable
        override fun call() {
            val transaction: SignedTransaction = TODO("Regular flow activity to agree transaction.")
    
            val auditor = serviceHub.identityService.partiesFromName("Auditor", true).single()
            val session = initiateFlow(auditor)
            subFlow(SendToAuditorFlow(session, transaction))
        }
    }
    

    或者,partyApartyB 可以从其节点的数据库中提取所有过去的交易,并将它们直接发送给审计员。然后审计员可以在平台外检查交易及其签名。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 1970-01-01
      • 2010-09-14
      • 1970-01-01
      相关资源
      最近更新 更多