add merge function for wallet transaction entry edge case

This commit is contained in:
Craig Raw 2023-01-19 14:12:35 +02:00
parent 276cb8aecb
commit 4ad9cdedb6

View file

@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.*; import java.util.*;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class WalletTransactionsEntry extends Entry { public class WalletTransactionsEntry extends Entry {
@ -68,7 +69,8 @@ public class WalletTransactionsEntry extends Entry {
public void updateTransactions() { public void updateTransactions() {
Map<HashIndex, BlockTransactionHashIndex> walletTxos = getWallet().getWalletTxos().entrySet().stream() Map<HashIndex, BlockTransactionHashIndex> walletTxos = getWallet().getWalletTxos().entrySet().stream()
.collect(Collectors.toUnmodifiableMap(entry -> new HashIndex(entry.getKey().getHash(), entry.getKey().getIndex()), Map.Entry::getKey)); .collect(Collectors.toUnmodifiableMap(entry -> new HashIndex(entry.getKey().getHash(), entry.getKey().getIndex()), Map.Entry::getKey,
BinaryOperator.maxBy(BlockTransactionHashIndex::compareTo)));
List<Entry> current = getWalletTransactions(getWallet()).stream().map(WalletTransaction::getTransactionEntry).collect(Collectors.toList()); List<Entry> current = getWalletTransactions(getWallet()).stream().map(WalletTransaction::getTransactionEntry).collect(Collectors.toList());
List<Entry> previous = new ArrayList<>(getChildren()); List<Entry> previous = new ArrayList<>(getChildren());