diff --git a/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecovery.kt b/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecovery.kt index aafd27503e..a85084b288 100644 --- a/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecovery.kt +++ b/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecovery.kt @@ -155,7 +155,7 @@ class DBTransactionStorageLedgerRecovery(private val database: CordaPersistence, val hashedDistributionList = HashedDistributionList( distributionList.senderStatesToRecord, hashedPeersToStatesToRecord, - HashedDistributionList.PublicHeader(senderRecordingTimestamp) + HashedDistributionList.PublicHeader(senderRecordingTimestamp, timeDiscriminator) ) hashedDistributionList.encrypt(encryptionService) } @@ -170,7 +170,7 @@ class DBTransactionStorageLedgerRecovery(private val database: CordaPersistence, val publicHeader = HashedDistributionList.PublicHeader.unauthenticatedDeserialise(distributionList.opaqueData, encryptionService) database.transaction { val receiverDistributionRecord = DBReceiverDistributionRecord( - Key(partyInfoCache.getPartyIdByCordaX500Name(sender), publicHeader.senderRecordedTimestamp), + Key(partyInfoCache.getPartyIdByCordaX500Name(sender), publicHeader.senderRecordedTimestamp, publicHeader.timeDiscriminator), txId, distributionList.opaqueData, distributionList.receiverStatesToRecord diff --git a/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt b/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt index 4f284f11b0..5fee0f24b2 100644 --- a/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt +++ b/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt @@ -38,12 +38,14 @@ data class HashedDistributionList( @CordaSerializable data class PublicHeader( - val senderRecordedTimestamp: Instant + val senderRecordedTimestamp: Instant, + val timeDiscriminator: Int ) { fun serialise(): ByteArray { - val buffer = ByteBuffer.allocate(1 + java.lang.Long.BYTES) + val buffer = ByteBuffer.allocate(1 + java.lang.Long.BYTES + Integer.BYTES) buffer.put(VERSION_TAG.toByte()) buffer.putLong(senderRecordedTimestamp.toEpochMilli()) + buffer.putInt(timeDiscriminator) return buffer.array() } @@ -67,7 +69,8 @@ data class HashedDistributionList( val version = buffer.get().toInt() require(version == VERSION_TAG) { "Unknown distribution list format $version" } val senderRecordedTimestamp = Instant.ofEpochMilli(buffer.getLong()) - return PublicHeader(senderRecordedTimestamp) + val timeDiscriminator = buffer.getInt() + return PublicHeader(senderRecordedTimestamp, timeDiscriminator) } catch (e: Exception) { throw IllegalArgumentException("Corrupt or not a distribution list header", e) } diff --git a/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecoveryTests.kt b/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecoveryTests.kt index debc39d102..85e086ad61 100644 --- a/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecoveryTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecoveryTests.kt @@ -320,7 +320,7 @@ class DBTransactionStorageLedgerRecoveryTests { val hashedDistList = HashedDistributionList( ALL_VISIBLE, mapOf(SecureHash.sha256(BOB.name.toString()) to NONE, SecureHash.sha256(CHARLIE_NAME.toString()) to ONLY_RELEVANT), - HashedDistributionList.PublicHeader(now()) + HashedDistributionList.PublicHeader(now(), 1) ) val roundtrip = HashedDistributionList.decrypt(hashedDistList.encrypt(encryptionService), encryptionService) assertThat(roundtrip).isEqualTo(hashedDistList)