Pre-generate Corda classes for DJVM sandbox when node boots in production mode.

This commit is contained in:
Chris Rankin 2019-10-17 17:48:19 +01:00
parent f208b054c3
commit 7b349ad049
7 changed files with 17 additions and 1 deletions

View File

@ -56,6 +56,7 @@ task patchCore(type: Zip, dependsOn: coreJarTask) {
archiveExtension = 'jar'
from(compileKotlin)
from(processResources)
from(zipTree(originalJar)) {
exclude 'net/corda/core/internal/*ToggleField*.class'
exclude 'net/corda/core/serialization/*SerializationFactory*.class'

View File

@ -216,7 +216,13 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
@Suppress("LeakingThis")
val transactionVerifierService = InMemoryTransactionVerifierService(transactionVerifierWorkerCount).tokenize()
val verifierFactoryService: VerifierFactoryService = if (djvmCordaSource != null) {
DeterministicVerifierFactoryService(djvmBootstrapSource, djvmCordaSource).tokenize()
DeterministicVerifierFactoryService(djvmBootstrapSource, djvmCordaSource).apply {
if (!configuration.devMode) {
log.info("Generating Corda classes for DJVM sandbox.")
generateSandbox()
}
tokenize()
}
} else {
BasicVerifierFactoryService()
}

View File

@ -46,6 +46,14 @@ class DeterministicVerifierFactoryService(
)
}
/**
* Generate sandbox classes for every Corda jar with META-INF/DJVM-preload.
*/
fun generateSandbox(): DeterministicVerifierFactoryService {
baseSandboxConfiguration.preload()
return this
}
override fun apply(ledgerTransaction: LedgerTransaction): LedgerTransaction {
// Specialise the LedgerTransaction here so that
// contracts are verified inside the DJVM!

View File

@ -54,6 +54,7 @@ task patchSerialization(type: Zip, dependsOn: serializationJarTask) {
archiveExtension = 'jar'
from(compileKotlin)
from(processResources)
from(zipTree(originalJar)) {
exclude 'net/corda/serialization/internal/AttachmentsClassLoaderBuilder*'
exclude 'net/corda/serialization/internal/ByteBufferStreams*'