Switch to individual services

This commit is contained in:
vanjatomic 2022-03-31 16:38:20 +01:00
parent 3af1ae1d56
commit d2e0f28578
3 changed files with 8 additions and 9 deletions

View File

@ -2,7 +2,7 @@
# because some versions here need to be matched by app authors in
# their own projects. So don't get fancy with syntax!
cordaVersion=4.8.5.16-CONCLAVE-SNAPSHOT
cordaVersion=4.8.5.17-CONCLAVE-SNAPSHOT
versionSuffix=
gradlePluginsVersion=5.0.12
kotlinVersion=1.2.71

View File

@ -5,7 +5,8 @@ import net.corda.core.conclave.common.dto.EncryptedVerifiableTxAndDependencies
import net.corda.core.conclave.common.dto.InputsAndRefsForNode
import net.corda.core.flows.FlowException
import net.corda.core.identity.CordaX500Name
import net.corda.core.node.ServicesForResolution
import net.corda.core.node.services.IdentityService
import net.corda.core.node.services.KeyManagementService
import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.transactions.EncryptedTransaction
import java.util.*
@ -15,7 +16,7 @@ import java.util.*
* data to arrive in a single ByteArray
*/
abstract class CordaEnclaveClient(val x500: CordaX500Name, val serviceHub: ServicesForResolution? = null): SingletonSerializeAsToken() {
abstract class CordaEnclaveClient(val x500: CordaX500Name, val keyManagementService: KeyManagementService? = null, val identityService: IdentityService? = null): SingletonSerializeAsToken() {
// Some exceptions we could throw [TBD - do we want this?]
class RemoteAttestationException(description: String) : FlowException(description)
@ -125,7 +126,7 @@ abstract class CordaEnclaveClient(val x500: CordaX500Name, val serviceHub: Servi
abstract fun decryptInputAndRefsForNode(encryptedTransaction: EncryptedTransaction): InputsAndRefsForNode
}
class DummyCordaEnclaveClient(x500: CordaX500Name, serviceHub: ServicesForResolution? = null): CordaEnclaveClient(x500, serviceHub) {
class DummyCordaEnclaveClient(x500: CordaX500Name, keyManagementService: KeyManagementService? = null, identityService: IdentityService? = null): CordaEnclaveClient(x500, keyManagementService, identityService) {
override fun getEnclaveInstanceInfo(): ByteArray {
throw UnsupportedOperationException("Add your custom enclave client implementation")

View File

@ -294,7 +294,6 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
@Suppress("LeakingThis")
val keyManagementService = makeKeyManagementService(identityService).tokenize()
val services = ServiceHubInternalImpl().tokenize()
val encryptedTransactionService = makeEncryptedTransactionService().tokenize()
val servicesForResolution = ServicesForResolutionImpl(identityService, attachments, cordappProvider, networkParametersStorage, transactionStorage, encryptedTransactionService).also {
@ -337,6 +336,7 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
})
}
val services = ServiceHubInternalImpl().tokenize()
val checkpointStorage = DBCheckpointStorage(DBCheckpointPerformanceRecorder(services.monitoringService.metrics), platformClock)
@Suppress("LeakingThis")
val smm = makeStateMachineManager()
@ -1066,10 +1066,8 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
null
}
return clazz?.let {
val internalServiceHub = ServicesForResolutionImpl(identityService, attachments, cordappProvider, networkParametersStorage, transactionStorage, EncryptedTransactionService()).also {
attachments.servicesForResolution = it
}
EncryptedTransactionService(Class.forName(it).getDeclaredConstructor(CordaX500Name::class.java, ServiceHub::class.java).newInstance(configuration.myLegalName, internalServiceHub) as CordaEnclaveClient)
EncryptedTransactionService(Class.forName(it).getDeclaredConstructor(CordaX500Name::class.java, KeyManagementService::class.java, IdentityService::class.java)
.newInstance(configuration.myLegalName, keyManagementService, identityService) as CordaEnclaveClient)
} ?: run {
EncryptedTransactionService()
}