Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of filtered offers and unsupported payment methods #4077

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ else if (maxTradeLimit == DEFAULT_TRADE_LIMIT_MID_RISK.value)
riskFactor = 4;
else if (maxTradeLimit == DEFAULT_TRADE_LIMIT_HIGH_RISK.value)
riskFactor = 8;
else
throw new RuntimeException("maxTradeLimit is not matching one of our default values. maxTradeLimit=" + Coin.valueOf(maxTradeLimit).toFriendlyString());
else {
riskFactor = 8;
log.error("maxTradeLimit is not matching one of our default values. maxTradeLimit=" + Coin.valueOf(maxTradeLimit).toFriendlyString());
}

TradeLimits tradeLimits = TradeLimits.getINSTANCE();
checkNotNull(tradeLimits, "tradeLimits must not be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package bisq.desktop.main.offer.offerbook;

import bisq.core.filter.FilterManager;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferBookService;
import bisq.core.trade.TradeManager;
Expand All @@ -37,7 +38,7 @@
import static bisq.core.offer.OfferPayload.Direction.BUY;

/**
* Holds and manages the unsorted and unfiltered offerbook list of both buy and sell offers.
* Holds and manages the unsorted and unfiltered offerbook list (except for banned offers) of both buy and sell offers.
* It is handled as singleton by Guice and is used by 2 instances of OfferBookDataModel (one for Buy one for Sell).
* As it is used only by the Buy and Sell UIs we treat it as local UI model.
* It also use OfferRepository.Listener as the lists items class and we don't want to get any dependency out of the
Expand All @@ -50,21 +51,30 @@ public class OfferBook {
private final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
private final Map<String, Integer> buyOfferCountMap = new HashMap<>();
private final Map<String, Integer> sellOfferCountMap = new HashMap<>();
private final FilterManager filterManager;

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////

@Inject
OfferBook(OfferBookService offerBookService, TradeManager tradeManager) {
OfferBook(OfferBookService offerBookService, TradeManager tradeManager, FilterManager filterManager) {
this.offerBookService = offerBookService;
this.filterManager = filterManager;

offerBookService.addOfferBookChangedListener(new OfferBookService.OfferBookChangedListener() {
@Override
public void onAdded(Offer offer) {
// We get onAdded called every time a new ProtectedStorageEntry is received.
// 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.
// We filter here to only add new offers if the same offer (using equals) was not already added and it
// is not banned.

if (filterManager.isOfferIdBanned(offer.getId())) {
log.debug("Ignored banned offer. ID={}", offer.getId());
return;
}

boolean hasSameOffer = offerBookListItems.stream()
.anyMatch(item -> item.getOffer().equals(offer));
if (!hasSameOffer) {
Expand Down Expand Up @@ -112,6 +122,7 @@ public void fillOfferBookListItems() {
// Investigate why....
offerBookListItems.clear();
offerBookListItems.addAll(offerBookService.getOffers().stream()
.filter(o -> !filterManager.isOfferIdBanned(o.getId()))
.map(OfferBookListItem::new)
.collect(Collectors.toList()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import javafx.scene.layout.HBox;

import javafx.geometry.Insets;
import javafx.geometry.Pos;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -145,8 +146,10 @@ public void onFault(String errorMessage) {

HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.setAlignment(Pos.CENTER_RIGHT);
GridPane.setRowIndex(hBox, ++rowIndex);
GridPane.setColumnIndex(hBox, 1);
GridPane.setColumnSpan(hBox, 2);
GridPane.setColumnIndex(hBox, 0);
hBox.getChildren().addAll(sendButton, closeButton);
gridPane.getChildren().add(hBox);
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
Expand Down