From f6c31aa479264e41160f8c1f3ad8b1dede68df41 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Thu, 4 May 2023 13:56:29 +0700 Subject: [PATCH] Remove added code with entryWithSameContextStillExists as it is not needed. Multiple calls will call add on the hashset but as the entry is the same it will not trigger any change of the hashset. Signed-off-by: HenrikJannsen --- .../bisq/core/btc/model/AddressEntryList.java | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/bisq/core/btc/model/AddressEntryList.java b/core/src/main/java/bisq/core/btc/model/AddressEntryList.java index 8b3c95b0e3..ccdc54412b 100644 --- a/core/src/main/java/bisq/core/btc/model/AddressEntryList.java +++ b/core/src/main/java/bisq/core/btc/model/AddressEntryList.java @@ -149,7 +149,7 @@ public final class AddressEntryList implements PersistableEnvelope, PersistedDat wallet.getIssuedReceiveAddresses().stream() .filter(this::isAddressNotInEntries) .forEach(address -> { - DeterministicKey key = (DeterministicKey) wallet.findKeyFromAddress(address); + DeterministicKey key = (DeterministicKey) wallet.findKeyFromAddress(address); if (key != null) { // Address will be derived from key in getAddress method log.info("Create AddressEntry for IssuedReceiveAddress. address={}", address.toString()); @@ -209,25 +209,11 @@ public final class AddressEntryList implements PersistableEnvelope, PersistedDat } log.info("swapToAvailable addressEntry to swap={}", addressEntry); - if (entrySet.remove(addressEntry)) { - requestPersistence(); - } - // check if the address still has any existing entries, which would be OCO offers sharing the UTXO - boolean entryWithSameContextStillExists = entrySet.stream().anyMatch(e -> { - if (addressEntry.getAddressString() != null) { - return addressEntry.getAddressString().equals(e.getAddressString()) && - addressEntry.getContext() == e.getContext(); - } - return false; - }); - if (entryWithSameContextStillExists) { - return; - } - // no other uses of the address context remain, so make it available - if (entrySet.add( - new AddressEntry(addressEntry.getKeyPair(), + boolean setChangedByRemove = entrySet.remove(addressEntry); + boolean setChangedByAdd = entrySet.add(new AddressEntry(addressEntry.getKeyPair(), AddressEntry.Context.AVAILABLE, - addressEntry.isSegwit()))) { + addressEntry.isSegwit())); + if (setChangedByRemove || setChangedByAdd) { requestPersistence(); } }