mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Fix OfferBookService bug causing extra check in OfferBook.onRemoved
Hash of protectedStorageEntry (should be offerPayload) was sometimes resulting in incorrect hash being sent to OfferBook listener methods onAdded(offer, hashOfPayload, sequenceNumber), and onRemoved(offer, hashOfPayload, sequenceNumber). Hash of OfferPayload is correctly passed to listener with this change. Sending the correct hash allows removal of a dubious code block that removed a book view list item when hash compare failed, and no matching offer existed in the OfferBookService. See https://github.com/bisq-network/bisq/pull/5659#discussion_r689634240
This commit is contained in:
parent
859a5ab4e4
commit
fb4e00fb6b
@ -94,7 +94,7 @@ public class OfferBookService {
|
||||
OfferPayload offerPayload = (OfferPayload) protectedStorageEntry.getProtectedStoragePayload();
|
||||
Offer offer = new Offer(offerPayload);
|
||||
offer.setPriceFeedService(priceFeedService);
|
||||
P2PDataStorage.ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStorageEntry);
|
||||
P2PDataStorage.ByteArray hashOfPayload = get32ByteHashAsByteArray(offerPayload);
|
||||
listener.onAdded(offer, hashOfPayload, protectedStorageEntry.getSequenceNumber());
|
||||
}
|
||||
}));
|
||||
@ -107,7 +107,7 @@ public class OfferBookService {
|
||||
OfferPayload offerPayload = (OfferPayload) protectedStorageEntry.getProtectedStoragePayload();
|
||||
Offer offer = new Offer(offerPayload);
|
||||
offer.setPriceFeedService(priceFeedService);
|
||||
P2PDataStorage.ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStorageEntry);
|
||||
P2PDataStorage.ByteArray hashOfPayload = get32ByteHashAsByteArray(offerPayload);
|
||||
listener.onRemoved(offer, hashOfPayload, protectedStorageEntry.getSequenceNumber());
|
||||
}
|
||||
}));
|
||||
|
@ -166,25 +166,6 @@ public class OfferBook {
|
||||
offer.getId(),
|
||||
hashOfPayload == null ? "null" : hashOfPayload.getHex());
|
||||
}
|
||||
|
||||
// The OfferBookListItem with a null or matching payload-hash was not found.
|
||||
// However, when the API's CLI is used to edit and deactivate an offer
|
||||
// in the same command, the edited offer is not re-published (and cannot be
|
||||
// found in local storage). In this case, we need to remove the deactivated
|
||||
// offer from the list if the local store does not contain an offer with a
|
||||
// matching offerId.
|
||||
if (!isStoredLocally(offer)) {
|
||||
Optional<OfferBookListItem> viewItem = getOfferBookListItem(offer);
|
||||
viewItem.ifPresent((item) -> {
|
||||
offerBookListItems.remove(item);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Storage does not contain an offer with id {} either;"
|
||||
+ " it is removed from UI view list.",
|
||||
offer.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user