mirror of
https://github.com/corda/corda.git
synced 2025-06-18 15:18:16 +00:00
Added notifyVault flag to recordTransaction and skip notify for irrelevant TX (#1250)
* Add notifyVault flag to recordTransaction to skip notifying the vault for transactions from ResolveTransactionFlow. * added methods for use in Java * reverted format changes * addressed PR issues changed recordTransaction method signature
This commit is contained in:
@ -801,9 +801,9 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
return flowFactories[initiatingFlowClass]
|
||||
}
|
||||
|
||||
override fun recordTransactions(txs: Iterable<SignedTransaction>) {
|
||||
override fun recordTransactions(notifyVault: Boolean, txs: Iterable<SignedTransaction>) {
|
||||
database.transaction {
|
||||
super.recordTransactions(txs)
|
||||
super.recordTransactions(notifyVault, txs)
|
||||
}
|
||||
}
|
||||
override fun jdbcSession(): Connection = database.createSession()
|
||||
|
@ -89,8 +89,8 @@ interface ServiceHubInternal : PluginServiceHub {
|
||||
val database: CordaPersistence
|
||||
val configuration: NodeConfiguration
|
||||
|
||||
override fun recordTransactions(txs: Iterable<SignedTransaction>) {
|
||||
require (txs.any()) { "No transactions passed in for recording" }
|
||||
override fun recordTransactions(notifyVault: Boolean, txs: Iterable<SignedTransaction>) {
|
||||
require(txs.any()) { "No transactions passed in for recording" }
|
||||
val recordedTransactions = txs.filter { validatedTransactions.addTransaction(it) }
|
||||
val stateMachineRunId = FlowStateMachineImpl.currentStateMachine()?.id
|
||||
if (stateMachineRunId != null) {
|
||||
@ -101,8 +101,10 @@ interface ServiceHubInternal : PluginServiceHub {
|
||||
log.warn("Transactions recorded from outside of a state machine")
|
||||
}
|
||||
|
||||
val toNotify = recordedTransactions.map { if (it.isNotaryChangeTransaction()) it.notaryChangeTx else it.tx }
|
||||
vaultService.notifyAll(toNotify)
|
||||
if (notifyVault) {
|
||||
val toNotify = recordedTransactions.map { if (it.isNotaryChangeTransaction()) it.notaryChangeTx else it.tx }
|
||||
vaultService.notifyAll(toNotify)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,6 @@ import java.lang.Exception
|
||||
import java.util.*
|
||||
import javax.persistence.Tuple
|
||||
|
||||
|
||||
class HibernateVaultQueryImpl(hibernateConfig: HibernateConfiguration,
|
||||
val vault: VaultService) : SingletonSerializeAsToken(), VaultQueryService {
|
||||
companion object {
|
||||
|
@ -75,7 +75,7 @@ class HibernateConfigurationTest : TestDependencyInjectionBase() {
|
||||
services = object : MockServices(BOB_KEY, BOC_KEY, DUMMY_NOTARY_KEY) {
|
||||
override val vaultService: VaultService = makeVaultService(dataSourceProps, hibernateConfig)
|
||||
|
||||
override fun recordTransactions(txs: Iterable<SignedTransaction>) {
|
||||
override fun recordTransactions(notifyVault: Boolean, txs: Iterable<SignedTransaction>) {
|
||||
for (stx in txs) {
|
||||
validatedTransactions.addTransaction(stx)
|
||||
}
|
||||
|
@ -94,13 +94,14 @@ class NodeVaultServiceTest : TestDependencyInjectionBase() {
|
||||
val originalVaultQuery = vaultQuery
|
||||
val services2 = object : MockServices() {
|
||||
override val vaultService: VaultService get() = originalVault
|
||||
override fun recordTransactions(txs: Iterable<SignedTransaction>) {
|
||||
override fun recordTransactions(notifyVault: Boolean, txs: Iterable<SignedTransaction>) {
|
||||
for (stx in txs) {
|
||||
validatedTransactions.addTransaction(stx)
|
||||
vaultService.notify(stx.tx)
|
||||
}
|
||||
}
|
||||
override val vaultQueryService : VaultQueryService get() = originalVaultQuery
|
||||
|
||||
override val vaultQueryService: VaultQueryService get() = originalVaultQuery
|
||||
}
|
||||
|
||||
val w2 = services2.vaultQueryService.queryBy<Cash.State>().states
|
||||
|
Reference in New Issue
Block a user