republish offers on dedicated thread for open offer manager

This commit is contained in:
woodser 2023-12-21 07:38:19 -05:00
parent a1f8f942fc
commit 0d33959eeb

View File

@ -1571,9 +1571,9 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
stopPeriodicRefreshOffersTimer(); stopPeriodicRefreshOffersTimer();
new Thread(() -> { HavenoUtils.submitToThread(() -> {
processListForRepublishOffers(getOpenOffers()); processListForRepublishOffers(getOpenOffers());
}).start(); }, THREAD_ID);
} }
private void processListForRepublishOffers(List<OpenOffer> list) { private void processListForRepublishOffers(List<OpenOffer> list) {
@ -1607,6 +1607,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
} }
private void republishOffer(OpenOffer openOffer, @Nullable Runnable completeHandler) { private void republishOffer(OpenOffer openOffer, @Nullable Runnable completeHandler) {
HavenoUtils.submitToThread(() -> {
// determine if offer is valid // determine if offer is valid
boolean isValid = true; boolean isValid = true;
@ -1653,7 +1654,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
OpenOffer updatedOpenOffer = new OpenOffer(updatedOffer, openOffer.getTriggerPrice()); OpenOffer updatedOpenOffer = new OpenOffer(updatedOffer, openOffer.getTriggerPrice());
// repost offer // repost offer
HavenoUtils.submitToThread(() -> {
synchronized (processOffersLock) { synchronized (processOffersLock) {
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
processUnpostedOffer(getOpenOffers(), updatedOpenOffer, (transaction) -> { processUnpostedOffer(getOpenOffers(), updatedOpenOffer, (transaction) -> {
@ -1670,8 +1670,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
}); });
HavenoUtils.awaitLatch(latch); HavenoUtils.awaitLatch(latch);
} }
}, THREAD_ID);
} }
}, THREAD_ID);
} }
private void startPeriodicRepublishOffersTimer() { private void startPeriodicRepublishOffersTimer() {