Correct handling of trying to record state more than once

* Check transactions to be recorded before filtering rather than after, as currently if the entire
list of transactions is already recorded, it's mis-reported as an empty input.
* Notify listeners only of recorded transactions, not all
This commit is contained in:
Ross Nicoll 2017-08-08 17:37:41 +01:00 committed by GitHub
parent 09f3dcd107
commit 1d965b1785

View File

@ -90,8 +90,8 @@ interface ServiceHubInternal : PluginServiceHub {
val configuration: NodeConfiguration
override fun recordTransactions(txs: Iterable<SignedTransaction>) {
require (txs.any()) { "No transactions passed in for recording" }
val recordedTransactions = txs.filter { validatedTransactions.addTransaction(it) }
require(recordedTransactions.isNotEmpty()) { "No transactions passed in for recording" }
val stateMachineRunId = FlowStateMachineImpl.currentStateMachine()?.id
if (stateMachineRunId != null) {
recordedTransactions.forEach {
@ -101,7 +101,7 @@ interface ServiceHubInternal : PluginServiceHub {
log.warn("Transactions recorded from outside of a state machine")
}
val toNotify = txs.map { if (it.isNotaryChangeTransaction()) it.notaryChangeTx else it.tx }
val toNotify = recordedTransactions.map { if (it.isNotaryChangeTransaction()) it.notaryChangeTx else it.tx }
vaultService.notifyAll(toNotify)
}