diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt index cde4f6ea19..d6918d9020 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt @@ -51,11 +51,22 @@ object UpdateBusinessDayFlow { @Suspendable override fun call(): Unit { progressTracker.currentStep = NOTIFYING - for (recipient in serviceHub.networkMapCache.partyNodes.sortedBy { it.legalIdentity.name }) { + for (recipient in getRecipients()) { doNextRecipient(recipient) } } + /** + * Returns recipients ordered by legal name, with notary nodes taking priority over party nodes. + * Ordering is required so that we avoid situations where on clock update a party starts a scheduled flow, but + * the notary or counterparty still use the old clock, so the timestamp on the transaction does not validate. + */ + private fun getRecipients(): Iterable<NodeInfo> { + val notaryNodes = serviceHub.networkMapCache.notaryNodes + val partyNodes = (serviceHub.networkMapCache.partyNodes - notaryNodes).sortedBy { it.legalIdentity.name } + return notaryNodes + partyNodes + } + @Suspendable private fun doNextRecipient(recipient: NodeInfo) { if (recipient.address is MockNetworkMapCache.MockAddress) {