mirror of
https://github.com/corda/corda.git
synced 2025-02-01 16:58:27 +00:00
Minor: provide a specialisation of SerializedBytes<WireTransaction>.deserialize() which caches the bytes properly.
This commit is contained in:
parent
48b2e561b7
commit
bab3c609c1
@ -66,7 +66,7 @@ data class WireTransaction(val inputs: List<StateRef>,
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun deserialize(bits: SerializedBytes<WireTransaction>): WireTransaction {
|
fun deserialize(bits: SerializedBytes<WireTransaction>): WireTransaction {
|
||||||
val wtx = bits.deserialize()
|
val wtx = bits.bits.deserialize<WireTransaction>()
|
||||||
wtx.cachedBits = bits
|
wtx.cachedBits = bits
|
||||||
return wtx
|
return wtx
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import com.esotericsoftware.kryo.io.Input
|
|||||||
import com.esotericsoftware.kryo.io.Output
|
import com.esotericsoftware.kryo.io.Output
|
||||||
import com.esotericsoftware.kryo.serializers.JavaSerializer
|
import com.esotericsoftware.kryo.serializers.JavaSerializer
|
||||||
import core.SignedTransaction
|
import core.SignedTransaction
|
||||||
|
import core.WireTransaction
|
||||||
import core.crypto.SecureHash
|
import core.crypto.SecureHash
|
||||||
import core.crypto.generateKeyPair
|
import core.crypto.generateKeyPair
|
||||||
import core.crypto.sha256
|
import core.crypto.sha256
|
||||||
@ -82,6 +83,9 @@ inline fun <reified T : Any> ByteArray.deserialize(kryo: Kryo = THREAD_LOCAL_KRY
|
|||||||
inline fun <reified T : Any> OpaqueBytes.deserialize(kryo: Kryo = THREAD_LOCAL_KRYO.get(), includeClassName: Boolean = false): T {
|
inline fun <reified T : Any> OpaqueBytes.deserialize(kryo: Kryo = THREAD_LOCAL_KRYO.get(), includeClassName: Boolean = false): T {
|
||||||
return this.bits.deserialize(kryo, includeClassName)
|
return this.bits.deserialize(kryo, includeClassName)
|
||||||
}
|
}
|
||||||
|
// The more specific deserialize version results in the bytes being cached, which is faster.
|
||||||
|
@JvmName("SerializedBytesWireTransaction")
|
||||||
|
fun SerializedBytes<WireTransaction>.deserialize(): WireTransaction = WireTransaction.deserialize(this)
|
||||||
inline fun <reified T : Any> SerializedBytes<T>.deserialize(): T = bits.deserialize()
|
inline fun <reified T : Any> SerializedBytes<T>.deserialize(): T = bits.deserialize()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user