mirror of
https://github.com/corda/corda.git
synced 2025-01-18 10:46:38 +00:00
CORDA-2975 Remove version uniqueness check
This commit is contained in:
parent
3b7f0aff92
commit
77ab33d5b0
@ -335,22 +335,6 @@ class NodeAttachmentService(
|
|||||||
currentDBSession().find(NodeAttachmentService.DBAttachment::class.java, attachmentId.toString()) != null
|
currentDBSession().find(NodeAttachmentService.DBAttachment::class.java, attachmentId.toString()) != null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun verifyVersionUniquenessForSignedAttachments(contractClassNames: List<ContractClassName>, contractVersion: Int, signers: List<PublicKey>?) {
|
|
||||||
if (signers != null && signers.isNotEmpty()) {
|
|
||||||
contractClassNames.forEach {
|
|
||||||
val existingContractsImplementations = queryAttachments(AttachmentQueryCriteria.AttachmentsQueryCriteria(
|
|
||||||
contractClassNamesCondition = Builder.equal(listOf(it)),
|
|
||||||
versionCondition = Builder.equal(contractVersion),
|
|
||||||
uploaderCondition = Builder.`in`(TRUSTED_UPLOADERS),
|
|
||||||
isSignedCondition = Builder.equal(true))
|
|
||||||
)
|
|
||||||
if (existingContractsImplementations.isNotEmpty()) {
|
|
||||||
throw DuplicateContractClassException(it, contractVersion, existingContractsImplementations.map { it.toString() })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun increaseDefaultVersionIfWhitelistedAttachment(contractClassNames: List<ContractClassName>, contractVersionFromFile: Int, attachmentId: AttachmentId) =
|
private fun increaseDefaultVersionIfWhitelistedAttachment(contractClassNames: List<ContractClassName>, contractVersionFromFile: Int, attachmentId: AttachmentId) =
|
||||||
if (contractVersionFromFile == DEFAULT_CORDAPP_VERSION) {
|
if (contractVersionFromFile == DEFAULT_CORDAPP_VERSION) {
|
||||||
val versions = contractClassNames.mapNotNull { servicesForResolution.networkParameters.whitelistedContractImplementations[it]?.indexOf(attachmentId) }
|
val versions = contractClassNames.mapNotNull { servicesForResolution.networkParameters.whitelistedContractImplementations[it]?.indexOf(attachmentId) }
|
||||||
@ -385,8 +369,6 @@ class NodeAttachmentService(
|
|||||||
val jarSigners = getSigners(bytes)
|
val jarSigners = getSigners(bytes)
|
||||||
val contractVersion = increaseDefaultVersionIfWhitelistedAttachment(contractClassNames, getVersion(bytes), id)
|
val contractVersion = increaseDefaultVersionIfWhitelistedAttachment(contractClassNames, getVersion(bytes), id)
|
||||||
val session = currentDBSession()
|
val session = currentDBSession()
|
||||||
if (!devMode)
|
|
||||||
verifyVersionUniquenessForSignedAttachments(contractClassNames, contractVersion, jarSigners)
|
|
||||||
val attachment = NodeAttachmentService.DBAttachment(
|
val attachment = NodeAttachmentService.DBAttachment(
|
||||||
attId = id.toString(),
|
attId = id.toString(),
|
||||||
content = bytes,
|
content = bytes,
|
||||||
@ -407,8 +389,6 @@ class NodeAttachmentService(
|
|||||||
val attachment = session.get(NodeAttachmentService.DBAttachment::class.java, id.toString())
|
val attachment = session.get(NodeAttachmentService.DBAttachment::class.java, id.toString())
|
||||||
// update the `uploader` field (as the existing attachment may have been resolved from a peer)
|
// update the `uploader` field (as the existing attachment may have been resolved from a peer)
|
||||||
if (attachment.uploader != uploader) {
|
if (attachment.uploader != uploader) {
|
||||||
if (!devMode)
|
|
||||||
verifyVersionUniquenessForSignedAttachments(contractClassNames, attachment.version, attachment.signers)
|
|
||||||
attachment.uploader = uploader
|
attachment.uploader = uploader
|
||||||
log.info("Updated attachment $id with uploader $uploader")
|
log.info("Updated attachment $id with uploader $uploader")
|
||||||
contractClassNames.forEach { contractsCache.invalidate(it) }
|
contractClassNames.forEach { contractsCache.invalidate(it) }
|
||||||
|
Loading…
Reference in New Issue
Block a user