[bisq-network/proposals] Filter offer listing by Base Currency (#142)

niyid notifications at github.com
Mon Nov 18 17:30:18 UTC 2019


> _This is a Bisq Network proposal. Please familiarize yourself with the [submission and review process](https://docs.bisq.network/proposals.html)._

<!-- Please do not remove the text above. -->
Checking the existing code, the design did consider having multiple base currencies. The current code for listing offers is below:

```
    public void fillOfferBookListItems() {
        try {
            // setAll causes sometimes an UnsupportedOperationException
            // Investigate why....
            offerBookListItems.clear();
            offerBookListItems.addAll(offerBookService.getOffers().stream()
                    .map(OfferBookListItem::new)
                    .collect(Collectors.toList()));

            log.debug("offerBookListItems.size {}", offerBookListItems.size());
            fillOfferCountMaps();
        } catch (Throwable t) {
            t.printStackTrace();
            log.error("Error at fillOfferBookListItems: " + t.toString());
        }
    }

```

I propose a change to:


```
    public void fillOfferBookListItems(String baseCurrency) {
        try {
            // setAll causes sometimes an UnsupportedOperationException
            // Investigate why....
            offerBookListItems.clear();
            offerBookListItems.addAll(offerBookService.getOffers().stream()
            		**.filter(new Predicate<>() {

						@Override
						public boolean test(Offer o) {
							return CurrencyUtil.isFiatCurrency(o.getCurrencyCode()) ? 
									baseCurrency.equals(o.getOfferPayload().getBaseCurrencyCode()) :
									baseCurrency.equals(o.getOfferPayload().getCounterCurrencyCode());
						}
					})**
                    .map(OfferBookListItem::new)
                    .collect(Collectors.toList()));

            log.debug("offerBookListItems.size {}", offerBookListItems.size());
            fillOfferCountMaps();
        } catch (Throwable t) {
            t.printStackTrace();
            log.error("Error at fillOfferBookListItems: " + t.toString());
        }
    }
```

This change will allow the filtering of the list by the base currency; such that offers made with base currency of "XMR" will not show up in listings where only offers with base currency of "BTC" should appear.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/proposals/issues/142
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191118/68ecbbfa/attachment.html>


More information about the bisq-github mailing list