diff --git a/node/src/main/kotlin/com/r3corda/node/driver/NodeRunner.kt b/node/src/main/kotlin/com/r3corda/node/driver/NodeRunner.kt index 1f96d50b12..8a7904cce4 100644 --- a/node/src/main/kotlin/com/r3corda/node/driver/NodeRunner.kt +++ b/node/src/main/kotlin/com/r3corda/node/driver/NodeRunner.kt @@ -27,7 +27,6 @@ class NodeRunner { companion object { @JvmStatic fun main(arguments: Array) { val cliParams = CliParams.parse(CliParams.parser.parse(*arguments)) - val nodeDirectory = Paths.get(cliParams.baseDirectory) createNodeRunDirectory(nodeDirectory) diff --git a/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt b/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt index 117df07d75..e5e949f8a2 100644 --- a/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt +++ b/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt @@ -256,7 +256,9 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration, if (NetworkMapService.Type in serviceTypes) makeNetworkMapService() val notaryServiceType = serviceTypes.singleOrNull { it.isSubTypeOf(NotaryService.Type) } - if (notaryServiceType != null) makeNotaryService(notaryServiceType) + if (notaryServiceType != null) { + inNodeNotaryService = makeNotaryService(notaryServiceType) + } } /** @@ -311,14 +313,16 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration, inNodeNetworkMapService = InMemoryNetworkMapService(net, reg, services.networkMapCache) } - open protected fun makeNotaryService(type: ServiceType) { + open protected fun makeNotaryService(type: ServiceType): NotaryService { val uniquenessProvider = InMemoryUniquenessProvider() val timestampChecker = TimestampChecker(platformClock, 30.seconds) - inNodeNotaryService = when (type) { - is SimpleNotaryService.Type -> SimpleNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache) - is ValidatingNotaryService.Type -> ValidatingNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache) - else -> null + return when (type) { + SimpleNotaryService.Type -> SimpleNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache) + ValidatingNotaryService.Type -> ValidatingNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache) + else -> { + throw IllegalArgumentException("Notary type ${type.id} is not handled by makeNotaryService.") + } } } diff --git a/node/src/main/kotlin/com/r3corda/node/services/transactions/NotaryService.kt b/node/src/main/kotlin/com/r3corda/node/services/transactions/NotaryService.kt index ad409fade3..bf60b126a6 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/transactions/NotaryService.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/transactions/NotaryService.kt @@ -24,6 +24,8 @@ abstract class NotaryService(val smm: StateMachineManager, val timestampChecker: TimestampChecker, val uniquenessProvider: UniquenessProvider, networkMapCache: NetworkMapCache) : AbstractNodeService(net, networkMapCache) { + // Do not specify this as an advertised service. Use a concrete implementation. + // TODO: We do not want a service type that cannot be used. Fix the type system abuse here. object Type : ServiceType("corda.notary") abstract val logger: org.slf4j.Logger diff --git a/node/src/test/kotlin/com/r3corda/node/driver/DriverTests.kt b/node/src/test/kotlin/com/r3corda/node/driver/DriverTests.kt index 311314cb7c..9e88ac3967 100644 --- a/node/src/test/kotlin/com/r3corda/node/driver/DriverTests.kt +++ b/node/src/test/kotlin/com/r3corda/node/driver/DriverTests.kt @@ -5,6 +5,7 @@ import com.r3corda.core.node.services.NetworkMapCache import com.r3corda.node.services.api.RegulatorService import com.r3corda.node.services.messaging.ArtemisMessagingComponent import com.r3corda.node.services.transactions.NotaryService +import com.r3corda.node.services.transactions.SimpleNotaryService import org.junit.Test @@ -32,7 +33,7 @@ class DriverTests { @Test fun simpleNodeStartupShutdownWorks() { val (notary, regulator) = driver { - val notary = startNode("TestNotary", setOf(NotaryService.Type)) + val notary = startNode("TestNotary", setOf(SimpleNotaryService.Type)) val regulator = startNode("Regulator", setOf(RegulatorService.Type)) nodeMustBeUp(networkMapCache, notary.get(), "TestNotary")