cordapp-tutorial 代码中是否需要 verify() 行?
Is the verify() line needed in the cordapp-tutorial code?
只是想知道,我注意到在 CollectSignaturesFlow 中有这个调用:
partiallySignedTx.tx.toLedgerTransaction(serviceHub).verify()
在 ExampleFlow 中有这一行:
txBuilder.toWireTransaction().toLedgerTransaction(serviceHub).verify()
两个地方都需要吗?他们调用的不是同一个套路吗?
你是对的 - 这些检查相互重复。在这种情况下,我们将其保留为良好实践的示例 - 并非每个人都在查看 CollectSignaturesFlow
!
的定义
但是,您可能希望在作为 try/catch 块的一部分签名之前验证交易,并在验证失败时修改交易(但是,这不是我们在这里所做的)。
另请注意:
partiallySignedTx.tx.toLedgerTransaction(serviceHub).verify()
实际上可以替换为:
partiallySignedTx.verify(serviceHub)
只是想知道,我注意到在 CollectSignaturesFlow 中有这个调用:
partiallySignedTx.tx.toLedgerTransaction(serviceHub).verify()
在 ExampleFlow 中有这一行:
txBuilder.toWireTransaction().toLedgerTransaction(serviceHub).verify()
两个地方都需要吗?他们调用的不是同一个套路吗?
你是对的 - 这些检查相互重复。在这种情况下,我们将其保留为良好实践的示例 - 并非每个人都在查看 CollectSignaturesFlow
!
但是,您可能希望在作为 try/catch 块的一部分签名之前验证交易,并在验证失败时修改交易(但是,这不是我们在这里所做的)。
另请注意:
partiallySignedTx.tx.toLedgerTransaction(serviceHub).verify()
实际上可以替换为:
partiallySignedTx.verify(serviceHub)