Refactor transaction serialization caching (#1078)

* Cache deserialized rather than serialized WireTransaction. Prevent repeated deserialization when adding signatures to the SignedTransaction.

* Added a test to check that stx copying and signature collection still works properly after (de)serialization
This commit is contained in:
Andrius Dagys
2017-07-24 14:48:39 +01:00
committed by GitHub
parent 3e199e51fc
commit d2eb5507f9
14 changed files with 71 additions and 52 deletions

View File

@ -605,7 +605,6 @@ class TwoPartyTradeFlowTests {
vararg extraSigningNodes: AbstractNode): Map<SecureHash, SignedTransaction> {
val signed = wtxToSign.map {
val bits = it.serialize()
val id = it.id
val sigs = mutableListOf<DigitalSignature.WithKey>()
sigs.add(node.services.keyManagementService.sign(id.bytes, node.services.legalIdentityKey))
@ -613,7 +612,7 @@ class TwoPartyTradeFlowTests {
extraSigningNodes.forEach { currentNode ->
sigs.add(currentNode.services.keyManagementService.sign(id.bytes, currentNode.info.legalIdentity.owningKey))
}
SignedTransaction(bits, sigs)
SignedTransaction(it, sigs)
}
return node.database.transaction {
node.services.recordTransactions(signed)

View File

@ -214,6 +214,6 @@ class RequeryConfigurationTest : TestDependencyInjectionBase() {
type = TransactionType.General,
timeWindow = null
)
return SignedTransaction(wtx.serialized, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
return SignedTransaction(wtx, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
}
}

View File

@ -152,6 +152,6 @@ class DBTransactionStorageTests : TestDependencyInjectionBase() {
type = TransactionType.General,
timeWindow = null
)
return SignedTransaction(wtx.serialized, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
return SignedTransaction(wtx, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
}
}