diff --git a/core/src/main/java/bisq/core/api/CoreOffersService.java b/core/src/main/java/bisq/core/api/CoreOffersService.java index aaf6574619..2c59402d7b 100644 --- a/core/src/main/java/bisq/core/api/CoreOffersService.java +++ b/core/src/main/java/bisq/core/api/CoreOffersService.java @@ -81,7 +81,6 @@ class CoreOffersService { private final OfferBookService offerBookService; private final OfferFilter offerFilter; private final OpenOfferManager openOfferManager; - private final OfferUtil offerUtil; private final User user; private final XmrWalletService xmrWalletService; @@ -103,7 +102,6 @@ class CoreOffersService { this.offerBookService = offerBookService; this.offerFilter = offerFilter; this.openOfferManager = openOfferManager; - this.offerUtil = offerUtil; this.user = user; this.xmrWalletService = xmrWalletService; } @@ -121,11 +119,13 @@ class CoreOffersService { } Offer getMyOffer(String id) { - return offerBookService.getOffers().stream() + Offer offer = offerBookService.getOffers().stream() .filter(o -> o.getId().equals(id)) .filter(o -> o.isMyOffer(keyRing)) .findAny().orElseThrow(() -> new IllegalStateException(format("offer with id '%s' not found", id))); + setOpenOfferState(offer); + return offer; } List getOffers(String direction, String currencyCode) { @@ -152,7 +152,7 @@ class CoreOffersService { .collect(Collectors.toList()); // remove unreserved offers - Set unreservedOffers = getUnreservedOffers(offers); + Set unreservedOffers = getUnreservedOffers(offers); // TODO (woodser): optimize performance, probably don't call here offers.removeAll(unreservedOffers); // remove my unreserved offers from offer manager @@ -162,11 +162,8 @@ class CoreOffersService { } openOfferManager.removeOpenOffers(unreservedOpenOffers, null); - // set offer state - for (Offer offer : offers) { - Optional openOffer = openOfferManager.getOpenOfferById(offer.getId()); - if (openOffer.isPresent()) offer.setState(openOffer.get().getState() == OpenOffer.State.AVAILABLE ? Offer.State.AVAILABLE : Offer.State.NOT_AVAILABLE); - } + // set offer states + for (Offer offer : offers) setOpenOfferState(offer); return offers; } @@ -322,11 +319,16 @@ class CoreOffersService { String direction, String currencyCode) { var offerOfWantedDirection = offer.getDirection().name().equalsIgnoreCase(direction); - var offerInWantedCurrency = offer.getOfferPayload().getCounterCurrencyCode() - .equalsIgnoreCase(currencyCode); + var counterAssetCode = isCryptoCurrency(currencyCode) ? offer.getOfferPayload().getBaseCurrencyCode() : offer.getOfferPayload().getCounterCurrencyCode(); // TODO: crypto pairs invert base and counter currencies + var offerInWantedCurrency = counterAssetCode.equalsIgnoreCase(currencyCode); return offerOfWantedDirection && offerInWantedCurrency; } + private void setOpenOfferState(Offer offer) { + Optional openOffer = openOfferManager.getOpenOfferById(offer.getId()); + if (openOffer.isPresent()) offer.setState(openOffer.get().getState() == OpenOffer.State.AVAILABLE ? Offer.State.AVAILABLE : Offer.State.NOT_AVAILABLE); + } + private Comparator priceComparator(String direction) { // A buyer probably wants to see sell orders in price ascending order. // A seller probably wants to see buy orders in price descending order. diff --git a/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java index f6f5a7c272..ca5a2db49f 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java +++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java @@ -193,8 +193,8 @@ class GrpcOffersService extends OffersImplBase { new HashMap<>() {{ put(getGetOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); put(getGetMyOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); - put(getGetOffersMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); - put(getGetMyOffersMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); + put(getGetOffersMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS)); + put(getGetMyOffersMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS)); put(getCreateOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); put(getCancelOfferMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); }}