From 6b97fbb79f9612b78a0e5b56dda1c54c1a5f28a3 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Tue, 4 Oct 2016 15:20:36 +0100 Subject: [PATCH] Removed ValidatingClient as notary behaviour is not client configurable --- .../kotlin/com/r3corda/protocols/NotaryProtocol.kt | 3 --- .../node/services/transactions/NotaryService.kt | 7 ++----- .../node/services/transactions/SimpleNotaryService.kt | 4 +--- .../services/transactions/ValidatingNotaryService.kt | 6 +----- .../node/services/ValidatingNotaryServiceTests.kt | 10 +++++----- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/core/src/main/kotlin/com/r3corda/protocols/NotaryProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/NotaryProtocol.kt index 36905b24ae..5a6f9e5154 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/NotaryProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/NotaryProtocol.kt @@ -75,9 +75,6 @@ object NotaryProtocol { } - class ValidatingClient(stx: SignedTransaction) : Client(stx) - - /** * Checks that the timestamp command is valid (if present) and commits the input state, or returns a conflict * if any of the input states have been previously committed. 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 65073d5a32..d0688a265e 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 @@ -5,7 +5,6 @@ import com.r3corda.core.node.services.ServiceType import com.r3corda.core.serialization.SingletonSerializeAsToken import com.r3corda.node.services.api.ServiceHubInternal import com.r3corda.protocols.NotaryProtocol -import kotlin.reflect.KClass /** * A Notary service acts as the final signer of a transaction ensuring two things: @@ -16,15 +15,13 @@ import kotlin.reflect.KClass * * This is the base implementation that can be customised with specific Notary transaction commit protocol. */ -abstract class NotaryService(markerClass: KClass, services: ServiceHubInternal) : SingletonSerializeAsToken() { +abstract class NotaryService(services: ServiceHubInternal) : SingletonSerializeAsToken() { // 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 - init { - services.registerProtocolInitiator(markerClass) { createProtocol(it) } + services.registerProtocolInitiator(NotaryProtocol.Client::class) { createProtocol(it) } } /** Implement a factory that specifies the transaction commit protocol for the notary service to use */ diff --git a/node/src/main/kotlin/com/r3corda/node/services/transactions/SimpleNotaryService.kt b/node/src/main/kotlin/com/r3corda/node/services/transactions/SimpleNotaryService.kt index 3f108b0e42..2f0fc51e0f 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/transactions/SimpleNotaryService.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/transactions/SimpleNotaryService.kt @@ -11,11 +11,9 @@ import com.r3corda.protocols.NotaryProtocol /** A simple Notary service that does not perform transaction validation */ class SimpleNotaryService(services: ServiceHubInternal, val timestampChecker: TimestampChecker, - val uniquenessProvider: UniquenessProvider) : NotaryService(NotaryProtocol.Client::class, services) { + val uniquenessProvider: UniquenessProvider) : NotaryService(services) { object Type : ServiceType("corda.notary.simple") - override val logger = loggerFor() - override fun createProtocol(otherParty: Party): NotaryProtocol.Service { return NotaryProtocol.Service(otherParty, timestampChecker, uniquenessProvider) } diff --git a/node/src/main/kotlin/com/r3corda/node/services/transactions/ValidatingNotaryService.kt b/node/src/main/kotlin/com/r3corda/node/services/transactions/ValidatingNotaryService.kt index 94d6c39ed3..01ae4ad02b 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/transactions/ValidatingNotaryService.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/transactions/ValidatingNotaryService.kt @@ -4,19 +4,15 @@ import com.r3corda.core.crypto.Party import com.r3corda.core.node.services.ServiceType import com.r3corda.core.node.services.TimestampChecker import com.r3corda.core.node.services.UniquenessProvider -import com.r3corda.core.utilities.loggerFor import com.r3corda.node.services.api.ServiceHubInternal -import com.r3corda.protocols.NotaryProtocol import com.r3corda.protocols.ValidatingNotaryProtocol /** A Notary service that validates the transaction chain of he submitted transaction before committing it */ class ValidatingNotaryService(services: ServiceHubInternal, val timestampChecker: TimestampChecker, - val uniquenessProvider: UniquenessProvider) : NotaryService(NotaryProtocol.ValidatingClient::class, services) { + val uniquenessProvider: UniquenessProvider) : NotaryService(services) { object Type : ServiceType("corda.notary.validating") - override val logger = loggerFor() - override fun createProtocol(otherParty: Party): ValidatingNotaryProtocol { return ValidatingNotaryProtocol(otherParty, timestampChecker, uniquenessProvider) } diff --git a/node/src/test/kotlin/com/r3corda/node/services/ValidatingNotaryServiceTests.kt b/node/src/test/kotlin/com/r3corda/node/services/ValidatingNotaryServiceTests.kt index 96250f0aca..7ac20e3557 100644 --- a/node/src/test/kotlin/com/r3corda/node/services/ValidatingNotaryServiceTests.kt +++ b/node/src/test/kotlin/com/r3corda/node/services/ValidatingNotaryServiceTests.kt @@ -5,8 +5,8 @@ import com.r3corda.core.contracts.Command import com.r3corda.core.contracts.DummyContract import com.r3corda.core.contracts.TransactionType import com.r3corda.core.crypto.DigitalSignature -import com.r3corda.core.transactions.SignedTransaction import com.r3corda.core.node.services.ServiceInfo +import com.r3corda.core.transactions.SignedTransaction import com.r3corda.core.utilities.DUMMY_NOTARY import com.r3corda.core.utilities.DUMMY_NOTARY_KEY import com.r3corda.node.services.network.NetworkMapService @@ -48,7 +48,7 @@ class ValidatingNotaryServiceTests { tx.toSignedTransaction(false) } - val future = runValidatingClient(stx) + val future = runClient(stx) val ex = assertFailsWith(ExecutionException::class) { future.get() } val notaryError = (ex.cause as NotaryException).error @@ -66,7 +66,7 @@ class ValidatingNotaryServiceTests { tx.toSignedTransaction(false) } - val future = runValidatingClient(stx) + val future = runClient(stx) val ex = assertFailsWith(ExecutionException::class) { future.get() } val notaryError = (ex.cause as NotaryException).error @@ -76,8 +76,8 @@ class ValidatingNotaryServiceTests { assertEquals(setOf(expectedMissingKey), missingKeys) } - private fun runValidatingClient(stx: SignedTransaction): ListenableFuture { - val protocol = NotaryProtocol.ValidatingClient(stx) + private fun runClient(stx: SignedTransaction): ListenableFuture { + val protocol = NotaryProtocol.Client(stx) val future = clientNode.services.startProtocol("notary", protocol) net.runNetwork() return future