This commit is contained in:
Manfred Karrer 2018-01-26 11:32:01 -05:00
parent f108836d1d
commit 50f9a790fd
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
2 changed files with 2 additions and 9 deletions

View file

@ -57,9 +57,7 @@ public class OfferBook {
// Mostly it is the same OfferPayload but the ProtectedStorageEntry is different.
// We filter here to only add new offers if the same offer (using equals) was not already added.
boolean hasSameOffer = offerBookListItems.stream()
.filter(item -> item.getOffer().equals(offer))
.findAny()
.isPresent();
.anyMatch(item -> item.getOffer().equals(offer));
if (!hasSameOffer) {
OfferBookListItem offerBookListItem = new OfferBookListItem(offer);
// We don't use the contains method as the equals method in Offer takes state and errorMessage into account.
@ -99,11 +97,6 @@ public class OfferBook {
});
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean isOfferWithIdInList(Offer offer) {
return offerBookListItems.stream().filter(o -> o.getOffer().getId().equals(offer.getId())).findAny().isPresent();
}
public ObservableList<OfferBookListItem> getOfferBookListItems() {
return offerBookListItems;
}

View file

@ -343,7 +343,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
if (!containsKey || hasSequenceNrIncreased) {
// At startup we don't have the item so we store it. At updates of the seq nr we store as well.
map.put(hashOfPayload, protectedStorageEntry);
hashMapChangedListeners.stream().forEach(e -> e.onAdded(protectedStorageEntry));
hashMapChangedListeners.forEach(e -> e.onAdded(protectedStorageEntry));
// printData("after add");
} else {
log.trace("We got that version of the data already, so we don't store it.");