重新构建和部署节点后使用现有数据的问题
issue in consuming existing data after re-build and deploy nodes
我使用创建了一笔交易。之后我对代码进行了一些更改并成功构建和部署了节点。我试图使用以前创建的数据来创建新数据。但是却导致Contract constraints failed错误。但是我在创建新数据并使用相同的数据在那个实例上创建另一个事务时没有得到任何错误。
TransactionVerificationException.ContractConstraintRejection
当您在保险库中有现有状态并且您更新了合约代码并重新部署时,将抛出此异常。
每次在节点启动时扫描 CorDapp 的 Jar 并将具有 Contract 类 的 Jar 上传到附件存储,并将 Jar 的 hash
作为 Attachment ID
将 contract
附加到 transaction
。
现在,考虑一下,你有第一个新版本的 CorDapp - Attachment ID
是:3B6CA18330500C738455444115C49769D54074CE3CFFB194D8943F34494DB0A4
要在 vault 上创建 State
,您构建 transaction
,Corda 使用上面给出的 Attachment ID
自动附加 contract
。
然后,考虑一下,你改变了代码并重新部署了CorDapp,现在jar hash改变了,新的Attachment ID
是:F054BA8C1A67BAABF58539F8718B8A62DC770157D9F1D01434B86E73AD2A9217
我的发现, 当你创建任何新的交易时,Corda 使用 new/recent Attachment ID
附加指定的 contract
.
例如,您想更新保管库中已有的状态。
a. You created a transaction which has one input and it's output state.
b. You sent this transaction for verification.
c. There is check verifies that input state
contract
Attachment Id
and current transaction
Attachment Id
must be same.
d. But right now input state
pointing to old Attachment ID
and transaction
pointing new Attachment ID
. Here check fails and throws a TransactionVerificationException.ContractConstraintRejection
exception.
我使用创建了一笔交易。之后我对代码进行了一些更改并成功构建和部署了节点。我试图使用以前创建的数据来创建新数据。但是却导致Contract constraints failed错误。但是我在创建新数据并使用相同的数据在那个实例上创建另一个事务时没有得到任何错误。
TransactionVerificationException.ContractConstraintRejection
当您在保险库中有现有状态并且您更新了合约代码并重新部署时,将抛出此异常。
每次在节点启动时扫描 CorDapp 的 Jar 并将具有 Contract 类 的 Jar 上传到附件存储,并将 Jar 的
hash
作为Attachment ID
将contract
附加到transaction
。现在,考虑一下,你有第一个新版本的 CorDapp -
Attachment ID
是:3B6CA18330500C738455444115C49769D54074CE3CFFB194D8943F34494DB0A4
要在 vault 上创建
State
,您构建transaction
,Corda 使用上面给出的Attachment ID
自动附加contract
。然后,考虑一下,你改变了代码并重新部署了CorDapp,现在jar hash改变了,新的
Attachment ID
是:F054BA8C1A67BAABF58539F8718B8A62DC770157D9F1D01434B86E73AD2A9217
我的发现, 当你创建任何新的交易时,Corda 使用 new/recent
Attachment ID
附加指定的contract
.例如,您想更新保管库中已有的状态。
a. You created a transaction which has one input and it's output state.
b. You sent this transaction for verification.
c. There is check verifies that
input state
contract
Attachment Id
and currenttransaction
Attachment Id
must be same.d. But right now
input state
pointing to oldAttachment ID
andtransaction
pointing newAttachment ID
. Here check fails and throws aTransactionVerificationException.ContractConstraintRejection
exception.