From d757429043dadd3fdf3f35ea6ed096eb339a75a9 Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Fri, 6 Jan 2017 12:24:27 +0000 Subject: [PATCH] Update the demo date in order: first notary, then party nodes ordered by name. --- .../net/corda/irs/flows/UpdateBusinessDayFlow.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 { + 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) {