mirror of
https://github.com/corda/corda.git
synced 2024-12-28 00:38:55 +00:00
Merge pull request #669 from corda/chrisr3-merge-os
ENT-1463: Instantiate all contract classes before verifying any of them.
This commit is contained in:
commit
626ff5ec77
@ -129,19 +129,26 @@ data class LedgerTransaction @JvmOverloads constructor(
|
||||
* If any contract fails to verify, the whole transaction is considered to be invalid.
|
||||
*/
|
||||
private fun verifyContracts() {
|
||||
val contractInstances = ArrayList<Contract>(contracts.size)
|
||||
for ((key, result) in contracts) {
|
||||
when (result) {
|
||||
is Try.Failure -> throw TransactionVerificationException.ContractCreationError(id, key, result.exception)
|
||||
is Try.Success -> {
|
||||
try {
|
||||
val contract = result.value.newInstance()
|
||||
contract.verify(this)
|
||||
contractInstances.add(result.value.newInstance())
|
||||
} catch (e: Throwable) {
|
||||
throw TransactionVerificationException.ContractRejection(id, result.value.name, e)
|
||||
throw TransactionVerificationException.ContractCreationError(id, result.value.name, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
contractInstances.forEach { contract ->
|
||||
try {
|
||||
contract.verify(this)
|
||||
} catch (e: Throwable) {
|
||||
throw TransactionVerificationException.ContractRejection(id, contract, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user