mirror of
https://github.com/corda/corda.git
synced 2025-04-11 13:21:26 +00:00
ENT-10110 timeDiscriminator must also be shared for DR synchronisation. (#7517)
This commit is contained in:
parent
a6254d54e3
commit
4e355b953b
node/src
main/kotlin/net/corda/node/services/persistence
test/kotlin/net/corda/node/services/persistence
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
2
node/src/test/kotlin/net/corda/node/services/persistence/DBTransactionStorageLedgerRecoveryTests.kt
2
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user