mirror of
https://github.com/corda/corda.git
synced 2025-04-07 11:27:01 +00:00
Merged in clint-no-notary-error (pull request #283)
Fixed bug when incorrect notary service type is specified.
This commit is contained in:
commit
668fecfea7
@ -27,7 +27,6 @@ class NodeRunner {
|
||||
companion object {
|
||||
@JvmStatic fun main(arguments: Array<String>) {
|
||||
val cliParams = CliParams.parse(CliParams.parser.parse(*arguments))
|
||||
|
||||
val nodeDirectory = Paths.get(cliParams.baseDirectory)
|
||||
createNodeRunDirectory(nodeDirectory)
|
||||
|
||||
|
@ -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.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user