process messages on user thread and protocol tasks off user thread

This commit is contained in:
woodser 2022-09-22 13:21:04 -04:00
parent cab508c7b5
commit c5f5a5af42
11 changed files with 392 additions and 368 deletions

View file

@ -42,6 +42,7 @@ import bisq.core.offer.Offer;
import bisq.core.offer.OfferDirection;
import bisq.core.offer.OpenOfferManager;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.TradeUtils;
import bisq.core.user.Preferences;
import bisq.core.util.VolumeUtil;
@ -66,6 +67,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;
class OfferBookChartViewModel extends ActivatableViewModel {
@ -125,19 +127,17 @@ class OfferBookChartViewModel extends ActivatableViewModel {
offerBookListItems = offerBook.getOfferBookListItems();
offerBookListItemsListener = c -> {
UserThread.execute(() -> {
c.next();
if (c.wasAdded() || c.wasRemoved()) {
ArrayList<OfferBookListItem> list = new ArrayList<>(c.getRemoved());
list.addAll(c.getAddedSubList());
if (list.stream()
.map(OfferBookListItem::getOffer)
.anyMatch(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())))
updateChartData();
}
c.next();
if (c.wasAdded() || c.wasRemoved()) {
ArrayList<OfferBookListItem> list = new ArrayList<>(c.getRemoved());
list.addAll(c.getAddedSubList());
if (list.stream()
.map(OfferBookListItem::getOffer)
.anyMatch(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())))
updateChartData();
}
fillTradeCurrencies();
});
fillTradeCurrencies();
};
currenciesUpdatedListener = (observable, oldValue, newValue) -> {