mirror of
https://github.com/corda/corda.git
synced 2024-12-22 06:17:55 +00:00
Substitute WireTransaction id property getter with calculated merkle root.
This commit is contained in:
parent
ea826988af
commit
6b5ad92f9b
@ -38,7 +38,16 @@ class WireTransaction(
|
|||||||
// Cache the serialised form of the transaction and its hash to give us fast access to it.
|
// Cache the serialised form of the transaction and its hash to give us fast access to it.
|
||||||
@Volatile @Transient private var cachedBits: SerializedBytes<WireTransaction>? = null
|
@Volatile @Transient private var cachedBits: SerializedBytes<WireTransaction>? = null
|
||||||
val serialized: SerializedBytes<WireTransaction> get() = cachedBits ?: serialize().apply { cachedBits = this }
|
val serialized: SerializedBytes<WireTransaction> get() = cachedBits ?: serialize().apply { cachedBits = this }
|
||||||
override val id: SecureHash get() = serialized.hash
|
// override val id: SecureHash get() = serialized.hash //todo remove
|
||||||
|
|
||||||
|
|
||||||
|
//We need cashed leaves hashed for Partial Merkle Tree calculation.
|
||||||
|
@Volatile @Transient private var cachedLeavesHashes: List<SecureHash>? = null
|
||||||
|
val allLeavesHashes: List<SecureHash> get() = cachedLeavesHashes ?: calculateLeavesHashes().apply { cachedLeavesHashes }
|
||||||
|
|
||||||
|
//TODO There is a problem with that it's failing 4 tests. Also in few places in code, there was reference to tx.serialized.hash
|
||||||
|
// instead of tx.id.
|
||||||
|
override val id: SecureHash get() = getMerkleRoot(allLeavesHashes)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun deserialize(bits: SerializedBytes<WireTransaction>, kryo: Kryo = THREAD_LOCAL_KRYO.get()): WireTransaction {
|
fun deserialize(bits: SerializedBytes<WireTransaction>, kryo: Kryo = THREAD_LOCAL_KRYO.get()): WireTransaction {
|
||||||
|
Loading…
Reference in New Issue
Block a user