mirror of
https://github.com/corda/corda.git
synced 2025-06-17 14:48:16 +00:00
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:
@ -90,8 +90,8 @@ interface ServiceHubInternal : PluginServiceHub {
|
|||||||
val configuration: NodeConfiguration
|
val configuration: NodeConfiguration
|
||||||
|
|
||||||
override fun recordTransactions(txs: Iterable<SignedTransaction>) {
|
override fun recordTransactions(txs: Iterable<SignedTransaction>) {
|
||||||
|
require (txs.any()) { "No transactions passed in for recording" }
|
||||||
val recordedTransactions = txs.filter { validatedTransactions.addTransaction(it) }
|
val recordedTransactions = txs.filter { validatedTransactions.addTransaction(it) }
|
||||||
require(recordedTransactions.isNotEmpty()) { "No transactions passed in for recording" }
|
|
||||||
val stateMachineRunId = FlowStateMachineImpl.currentStateMachine()?.id
|
val stateMachineRunId = FlowStateMachineImpl.currentStateMachine()?.id
|
||||||
if (stateMachineRunId != null) {
|
if (stateMachineRunId != null) {
|
||||||
recordedTransactions.forEach {
|
recordedTransactions.forEach {
|
||||||
@ -101,7 +101,7 @@ interface ServiceHubInternal : PluginServiceHub {
|
|||||||
log.warn("Transactions recorded from outside of a state machine")
|
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)
|
vaultService.notifyAll(toNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user