mirror of
https://github.com/corda/corda.git
synced 2025-04-29 15:30:10 +00:00
Revert unnecessary refactoring.
This commit is contained in:
parent
758c855493
commit
a17ab0d547
@ -7,7 +7,6 @@ import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.crypto.isFulfilledBy
|
||||
import net.corda.core.internal.AttachmentWithContext
|
||||
import net.corda.core.internal.isUploaderTrusted
|
||||
import net.corda.core.internal.warnOnce
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.utilities.loggerFor
|
||||
@ -52,21 +51,14 @@ data class HashAttachmentConstraint(val attachmentId: SecureHash) : AttachmentCo
|
||||
val disableHashConstraints = System.getProperty("net.corda.node.disableHashConstraints")?.toBoolean() ?: false
|
||||
}
|
||||
override fun isSatisfiedBy(attachment: Attachment): Boolean {
|
||||
return when {
|
||||
disableHashConstraints -> {
|
||||
log.warnOnce("Skipping hash constraints verification.")
|
||||
true
|
||||
}
|
||||
attachment is AttachmentWithContext -> {
|
||||
return if (attachment is AttachmentWithContext) {
|
||||
log.debug("Checking attachment uploader ${attachment.contractAttachment.uploader} is trusted")
|
||||
attachment.id == attachmentId && isUploaderTrusted(attachment.contractAttachment.uploader)
|
||||
}
|
||||
else -> {
|
||||
} else {
|
||||
log.warn("Hash constraint check failed: $attachmentId does not match contract attachment JAR ${attachment.id} or contract attachment JAR is untrusted")
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -338,11 +338,12 @@ class Verifier(val ltx: LedgerTransaction,
|
||||
|
||||
val constraintAttachment = AttachmentWithContext(contractAttachment, contract, ltx.networkParameters!!.whitelistedContractImplementations)
|
||||
|
||||
if (!constraint.isSatisfiedBy(constraintAttachment)) {
|
||||
if (HashAttachmentConstraint.disableHashConstraints && constraint is HashAttachmentConstraint)
|
||||
logger.warnOnce("Skipping hash constraints verification.")
|
||||
else if (!constraint.isSatisfiedBy(constraintAttachment))
|
||||
throw TransactionVerificationException.ContractConstraintRejection(ltx.id, contract)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the transaction is contract-valid by running the verify() for each input and output state contract.
|
||||
|
Loading…
x
Reference in New Issue
Block a user