mirror of
https://github.com/corda/corda.git
synced 2025-06-05 00:50:52 +00:00
Run filterMyKeys only when required (in NodeVaultService) (#3014)
This commit is contained in:
parent
4ba794bc1a
commit
5bbfde3d35
@ -128,10 +128,9 @@ class NodeVaultService(
|
|||||||
|
|
||||||
private fun makeUpdates(batch: Iterable<CoreTransaction>, statesToRecord: StatesToRecord): List<Vault.Update<ContractState>> {
|
private fun makeUpdates(batch: Iterable<CoreTransaction>, statesToRecord: StatesToRecord): List<Vault.Update<ContractState>> {
|
||||||
fun makeUpdate(tx: WireTransaction): Vault.Update<ContractState>? {
|
fun makeUpdate(tx: WireTransaction): Vault.Update<ContractState>? {
|
||||||
val myKeys = keyManagementService.filterMyKeys(tx.outputs.flatMap { it.data.participants.map { it.owningKey } })
|
|
||||||
val ourNewStates = when (statesToRecord) {
|
val ourNewStates = when (statesToRecord) {
|
||||||
StatesToRecord.NONE -> throw AssertionError("Should not reach here")
|
StatesToRecord.NONE -> throw AssertionError("Should not reach here")
|
||||||
StatesToRecord.ONLY_RELEVANT -> tx.outputs.filter { isRelevant(it.data, myKeys.toSet()) }
|
StatesToRecord.ONLY_RELEVANT -> tx.outputs.filter { isRelevant(it.data, keyManagementService.filterMyKeys(tx.outputs.flatMap { it.data.participants.map { it.owningKey } }).toSet()) }
|
||||||
StatesToRecord.ALL_VISIBLE -> tx.outputs
|
StatesToRecord.ALL_VISIBLE -> tx.outputs
|
||||||
}.map { tx.outRef<ContractState>(it.data) }
|
}.map { tx.outRef<ContractState>(it.data) }
|
||||||
|
|
||||||
@ -156,12 +155,15 @@ class NodeVaultService(
|
|||||||
is ContractUpgradeWireTransaction -> tx.resolve(servicesForResolution, emptyList())
|
is ContractUpgradeWireTransaction -> tx.resolve(servicesForResolution, emptyList())
|
||||||
else -> throw IllegalArgumentException("Unsupported transaction type: ${tx.javaClass.name}")
|
else -> throw IllegalArgumentException("Unsupported transaction type: ${tx.javaClass.name}")
|
||||||
}
|
}
|
||||||
val myKeys = keyManagementService.filterMyKeys(ltx.outputs.flatMap { it.data.participants.map { it.owningKey } })
|
val myKeys by lazy { keyManagementService.filterMyKeys(ltx.outputs.flatMap { it.data.participants.map { it.owningKey } }) }
|
||||||
val (consumedStateAndRefs, producedStates) = ltx.inputs.
|
val (consumedStateAndRefs, producedStates) = ltx.inputs.
|
||||||
zip(ltx.outputs).
|
zip(ltx.outputs).
|
||||||
filter { (_, output) ->
|
filter { (_, output) ->
|
||||||
if (statesToRecord == StatesToRecord.ONLY_RELEVANT) isRelevant(output.data, myKeys.toSet())
|
if (statesToRecord == StatesToRecord.ONLY_RELEVANT) {
|
||||||
else true
|
isRelevant(output.data, myKeys.toSet())
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
}.
|
}.
|
||||||
unzip()
|
unzip()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user