improve performance of wallet transactions update

This commit is contained in:
Craig Raw 2024-09-12 14:29:21 +02:00
parent 87b5f992d0
commit 6b89a0c5ea

View file

@ -421,8 +421,10 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
public synchronized void updateTransactions(Map<Sha256Hash, BlockTransaction> updatedTransactions) { public synchronized void updateTransactions(Map<Sha256Hash, BlockTransaction> updatedTransactions) {
for(BlockTransaction blockTx : updatedTransactions.values()) { for(BlockTransaction blockTx : updatedTransactions.values()) {
if(!transactions.isEmpty()) { if(!transactions.isEmpty()) {
Optional<String> optionalLabel = transactions.values().stream().filter(oldBlTx -> oldBlTx.getHash().equals(blockTx.getHash())).map(BlockTransaction::getLabel).filter(Objects::nonNull).findFirst(); BlockTransaction oldTx = transactions.get(blockTx.getHash());
optionalLabel.ifPresent(blockTx::setLabel); if(oldTx != null && oldTx.getLabel() != null) {
blockTx.setLabel(oldTx.getLabel());
}
} }
if(!detachedLabels.isEmpty()) { if(!detachedLabels.isEmpty()) {