mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +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,17 +129,24 @@ data class LedgerTransaction @JvmOverloads constructor(
|
|||||||
* If any contract fails to verify, the whole transaction is considered to be invalid.
|
* If any contract fails to verify, the whole transaction is considered to be invalid.
|
||||||
*/
|
*/
|
||||||
private fun verifyContracts() {
|
private fun verifyContracts() {
|
||||||
|
val contractInstances = ArrayList<Contract>(contracts.size)
|
||||||
for ((key, result) in contracts) {
|
for ((key, result) in contracts) {
|
||||||
when (result) {
|
when (result) {
|
||||||
is Try.Failure -> throw TransactionVerificationException.ContractCreationError(id, key, result.exception)
|
is Try.Failure -> throw TransactionVerificationException.ContractCreationError(id, key, result.exception)
|
||||||
is Try.Success -> {
|
is Try.Success -> {
|
||||||
try {
|
try {
|
||||||
val contract = result.value.newInstance()
|
contractInstances.add(result.value.newInstance())
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
throw TransactionVerificationException.ContractCreationError(id, result.value.name, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contractInstances.forEach { contract ->
|
||||||
|
try {
|
||||||
contract.verify(this)
|
contract.verify(this)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
throw TransactionVerificationException.ContractRejection(id, result.value.name, e)
|
throw TransactionVerificationException.ContractRejection(id, contract, e)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user