<p></p>
<blockquote>
<blockquote>
<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/ghubstan/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ghubstan">@ghubstan</a>: If the <code>offerFilter.canTakeOffer</code> call can be included in <code>getOffers(String direction, String currencyCode)</code> and <code>getOffer(String id)</code>, we can remove the <code>getOffersAvailableForTaker</code> method.</p>
</blockquote>
</blockquote>
<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/chimp1984/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/chimp1984">@chimp1984</a> If you want to back out that new core api <code>getOffersAvailableForTaker</code> method, add the two lines (commented in the snippet below as /* HERE */).  I'll test if you make the suggested change in the PR.</p>
<pre><code>// TODO should we add a check for offerFilter.canTakeOffer?
Offer getOffer(String id) {
    return offerBookService.getOffers().stream()
            .filter(o -> o.getId().equals(id))
            .filter(o -> offerFilter.canTakeOffer(o, true).isValid())   /* HERE */
            .findAny().orElseThrow(() ->
                    new IllegalStateException(format("offer with id '%s' not found", id)));
}

// TODO returns all offers also those which cannot be taken. Should we use the filter from
//  getOffersAvailableForTaker here and remove the getOffersAvailableForTaker method?
List<Offer> getOffers(String direction, String currencyCode) {
    List<Offer> offers = offerBookService.getOffers().stream()
            .filter(o -> {
                var offerOfWantedDirection = o.getDirection().name().equalsIgnoreCase(direction);
                var offerInWantedCurrency = o.getOfferPayload().getCounterCurrencyCode()
                        .equalsIgnoreCase(currencyCode);
                return offerOfWantedDirection && offerInWantedCurrency;
            })
            .filter(o -> offerFilter.canTakeOffer(o, true).isValid())        /* HERE */
            .collect(Collectors.toList());

    // 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));

    return offers;
}
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/5053#issuecomment-754200017">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNSBXE35MXZUOAC3FHTSYIQH3ANCNFSM4VTLWMTA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNTV2JLEEEX5NZ3WRGTSYIQH3A5CNFSM4VTLWMTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFT2C3UI.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/5053#issuecomment-754200017",
"url": "https://github.com/bisq-network/bisq/pull/5053#issuecomment-754200017",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>