Merge commit 'cb670dcb6255aa07c2b06fe1e381d0c4d032634c' into chrisr3-merge-os

This commit is contained in:
Chris Rankin 2018-04-03 13:21:01 +01:00
commit 5c32f34838

View File

@ -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)
}
}
}
/**