mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Fix issue with TriggerPriceService deactivating offer too early
TriggerPriceService is changed to use a BootstrapListener on the P2PService so that it can start after the P2P network is ready. Fixes #5190 : Prevents an Uncaught Exception error at startup.
This commit is contained in:
parent
31b7292d56
commit
d82a61d0a6
@ -23,6 +23,9 @@ import bisq.core.monetary.Price;
|
||||
import bisq.core.provider.price.MarketPrice;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
|
||||
import bisq.network.p2p.BootstrapListener;
|
||||
import bisq.network.p2p.P2PService;
|
||||
|
||||
import bisq.common.util.MathUtils;
|
||||
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
@ -47,17 +50,34 @@ import static bisq.common.util.MathUtils.scaleUpByPowerOf10;
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class TriggerPriceService {
|
||||
private final P2PService p2PService;
|
||||
private final OpenOfferManager openOfferManager;
|
||||
private final PriceFeedService priceFeedService;
|
||||
private final Map<String, Set<OpenOffer>> openOffersByCurrency = new HashMap<>();
|
||||
|
||||
@Inject
|
||||
public TriggerPriceService(OpenOfferManager openOfferManager, PriceFeedService priceFeedService) {
|
||||
public TriggerPriceService(P2PService p2PService,
|
||||
OpenOfferManager openOfferManager,
|
||||
PriceFeedService priceFeedService) {
|
||||
this.p2PService = p2PService;
|
||||
this.openOfferManager = openOfferManager;
|
||||
this.priceFeedService = priceFeedService;
|
||||
}
|
||||
|
||||
public void onAllServicesInitialized() {
|
||||
if (p2PService.isBootstrapped()) {
|
||||
onBootstrapComplete();
|
||||
} else {
|
||||
p2PService.addP2PServiceListener(new BootstrapListener() {
|
||||
@Override
|
||||
public void onUpdatedDataReceived() {
|
||||
onBootstrapComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void onBootstrapComplete() {
|
||||
openOfferManager.getObservableList().addListener((ListChangeListener<OpenOffer>) c -> {
|
||||
c.next();
|
||||
if (c.wasAdded()) {
|
||||
|
Loading…
Reference in New Issue
Block a user