From 6b89a0c5ea7a63e1b410abe9963f20ce83763798 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 12 Sep 2024 14:29:21 +0200 Subject: [PATCH] improve performance of wallet transactions update --- src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index d662f63..7b28c9e 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -421,8 +421,10 @@ public class Wallet extends Persistable implements Comparable { public synchronized void updateTransactions(Map updatedTransactions) { for(BlockTransaction blockTx : updatedTransactions.values()) { if(!transactions.isEmpty()) { - Optional optionalLabel = transactions.values().stream().filter(oldBlTx -> oldBlTx.getHash().equals(blockTx.getHash())).map(BlockTransaction::getLabel).filter(Objects::nonNull).findFirst(); - optionalLabel.ifPresent(blockTx::setLabel); + BlockTransaction oldTx = transactions.get(blockTx.getHash()); + if(oldTx != null && oldTx.getLabel() != null) { + blockTx.setLabel(oldTx.getLabel()); + } } if(!detachedLabels.isEmpty()) {