Corda Walking the Chain in finalityFlow

喜你入骨 提交于 2019-12-25 01:50:02

问题


In Corda, FinalityFlow:

  1. Verifies transaction on initiator node
  2. Notarizes transaction
  3. Persists signedTransaction to vault of initiator
  4. Distributes transaction to the participants

As per consensus, verification involves walking the chain.

I looked in FinalityFlow code. Where exactly does the walking-the-chain thing happen?

Do the notary and the participants also walk the chain? If yes, they check the signatures on each transaction in the chain, but where exactly in the code does it happen?

As per my understanding, SendTransactionFlow sends the transaction to the other parties on the participants lists. The other party also requests for attachments and transaction dependencies. Where actually does the walking-the-chain thing happen?

I need to understand walking the chain from a coding perspective.


回答1:


In FinalityFlow, the caller uses the following line to send the notarised transaction to the participants of all the states:

subFlow(SendTransactionFlow(session, notarised))

If we look at AbstractNode.installCoreFlows, we see that the node installs a default handler for FinalityFlow called FinalityHandler. FinalityHandler responds to the call to SendTransactionFlow in FinalityFlow by calling ReceiveTransactionFlow.

Inside ReceiveTransactionFlow, we can see that the node resolves the transaction's dependencies, verifies the transaction and checks its signatures:

val stx = otherSideSession.receive<SignedTransaction>().unwrap {
    subFlow(ResolveTransactionsFlow(it, otherSideSession))
    it.verify(serviceHub, checkSufficientSignatures)
    it
}

As part of resolving the transaction's dependencies in ResolveTransactionsFlow, the node verifies each one and checks its signatures (by default, verify checks the signatures on the transaction):

result.forEach {
    it.verify(serviceHub)
    serviceHub.recordTransactions(StatesToRecord.NONE, listOf(it))
}

The notary will only walk the chain in this way if they are a validating notary.



来源:https://stackoverflow.com/questions/53314281/corda-walking-the-chain-in-finalityflow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!