From 8e6198cf91336c6223dd01a67965894169abdeb4 Mon Sep 17 00:00:00 2001 From: Andras Slemmer Date: Thu, 8 Sep 2016 10:15:59 +0100 Subject: [PATCH] core: Make topological sort result deterministic --- .../com/r3corda/protocols/ResolveTransactionsProtocol.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/com/r3corda/protocols/ResolveTransactionsProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/ResolveTransactionsProtocol.kt index 456a7dd60f..4230e4899f 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/ResolveTransactionsProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/ResolveTransactionsProtocol.kt @@ -39,7 +39,8 @@ class ResolveTransactionsProtocol(private val txHashes: Set, val forwardGraph = HashMap>() transactions.forEach { tx -> tx.tx.inputs.forEach { input -> - forwardGraph.getOrPut(input.txhash) { HashSet() }.add(tx) + // Note that we use a LinkedHashSet here to make the traversal deterministic (as long as the input list is) + forwardGraph.getOrPut(input.txhash) { LinkedHashSet() }.add(tx) } }