mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Merge pull request #5191 from jmacxx/fix_TriggerPriceService_bootstrap
Fix startup error: "You must have bootstrapped before adding data to the P2P network"
This commit is contained in:
commit
43ac2c9e57
1 changed files with 21 additions and 1 deletions
|
@ -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…
Add table
Reference in a new issue