[bisq-network/bisq] Add new api methods 'getmyoffers' and 'getmyoffer' (#5056)

sqrrm notifications at github.com
Thu Jan 7 22:51:40 CET 2021


@sqrrm commented on this pull request.



>  
-        // A buyer probably wants to see sell orders in price ascending order.
-        // A seller probably wants to see buy orders in price descending order.
-        if (direction.equalsIgnoreCase(BUY.name()))
-            offers.sort(Comparator.comparing(Offer::getPrice).reversed());
-        else
-            offers.sort(Comparator.comparing(Offer::getPrice));
-
+    List<Offer> getMyOffers(String direction, String currencyCode) {
+        List<Offer> offers = offerBookService.getOffers().stream()
+                .filter(o -> o.isMyOffer(keyRing))
+                .filter(o -> offerMatchesDirectionAndCurrency(o, direction, currencyCode))
+                .collect(Collectors.toList());
+        sortOffers(offers, direction);

Yeah. Since the stream is there anyway I'm thinking it would be possible to do some optimization by the stream interface, but I'm not sure. It's also easier to follow all the operations on Collection when lined up in stream operations. The Collection.sort() is probably more efficient as a stand alone sort method though.

-- 
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/bisq/pull/5056#discussion_r553611336
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210107/906b2406/attachment.htm>


More information about the bisq-github mailing list