From c5500caf98106e33b8cddcdfc0dfb8f1343c9141 Mon Sep 17 00:00:00 2001 From: Jose Coll Date: Tue, 1 Nov 2016 11:39:11 +0000 Subject: [PATCH] Minor changes to address PR feedback and comments --- .../kotlin/com/r3corda/core/node/services/Services.kt | 3 +++ .../r3corda/node/services/vault/NodeVaultService.kt | 10 ++-------- .../com/r3corda/node/services/NodeVaultServiceTest.kt | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/core/src/main/kotlin/com/r3corda/core/node/services/Services.kt b/core/src/main/kotlin/com/r3corda/core/node/services/Services.kt index c310b321cb..e459f7269e 100644 --- a/core/src/main/kotlin/com/r3corda/core/node/services/Services.kt +++ b/core/src/main/kotlin/com/r3corda/core/node/services/Services.kt @@ -168,6 +168,9 @@ interface VaultService { /** * Add a note to an existing [LedgerTransaction] given by its unique [SecureHash] id + * Multiple notes may be attached to the same [LedgerTransaction]. + * These are additively and immutably persisted within the node local vault database in a single textual field + * using a semi-colon separator */ fun addNoteToTransaction(txnId: SecureHash, noteText: String) diff --git a/node/src/main/kotlin/com/r3corda/node/services/vault/NodeVaultService.kt b/node/src/main/kotlin/com/r3corda/node/services/vault/NodeVaultService.kt index e51459d6ee..9b0ca211dc 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/vault/NodeVaultService.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/vault/NodeVaultService.kt @@ -77,10 +77,6 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT } } - fun allTransactionNotes(): Map> { - return transactionNotes - } - val _updatesPublisher = PublishSubject.create() fun allUnconsumedStates(): Iterable> { @@ -104,14 +100,14 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT } }) - override val currentVault: Vault get() = mutex.locked { Vault(allUnconsumedStates(), allTransactionNotes()) } + override val currentVault: Vault get() = mutex.locked { Vault(allUnconsumedStates(), transactionNotes) } override val updates: Observable get() = mutex.locked { _updatesPublisher } override fun track(): Pair> { return mutex.locked { - Pair(Vault(allUnconsumedStates(), allTransactionNotes()), _updatesPublisher.bufferUntilSubscribed()) + Pair(Vault(allUnconsumedStates(), transactionNotes), _updatesPublisher.bufferUntilSubscribed()) } } @@ -135,7 +131,6 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT return currentVault } - override fun addNoteToTransaction(txnId: SecureHash, noteText: String) { mutex.locked { val notes = transactionNotes.getOrPut(key = txnId, defaultValue = { @@ -300,5 +295,4 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT false } } - } diff --git a/node/src/test/kotlin/com/r3corda/node/services/NodeVaultServiceTest.kt b/node/src/test/kotlin/com/r3corda/node/services/NodeVaultServiceTest.kt index 1209c09bce..5d582522a5 100644 --- a/node/src/test/kotlin/com/r3corda/node/services/NodeVaultServiceTest.kt +++ b/node/src/test/kotlin/com/r3corda/node/services/NodeVaultServiceTest.kt @@ -85,7 +85,6 @@ class NodeVaultServiceTest { @Test fun addNoteToTransaction() { - databaseTransaction(database) { val services = object : MockServices() { override val vaultService: VaultService = NodeVaultService(this)