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 <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2023-05-04 13:56:29 +07:00
parent 966b9d8448
commit f6c31aa479
No known key found for this signature in database
GPG Key ID: 02AA2BAE387C8307

View File

@ -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();
}
}