mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
fix startup issues in some cases, where the p2pservice calls an onmessage before the storagefile is initialised.
Aligning Api module with other modules by using the AppSetupWithP2P class.
This commit is contained in:
parent
46641200bc
commit
9101aa367b
2 changed files with 11 additions and 53 deletions
|
@ -3,6 +3,8 @@ package io.bisq.api.app;
|
|||
import ch.qos.logback.classic.Level;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.name.Names;
|
||||
import io.bisq.api.service.DropwizardApplication;
|
||||
import io.bisq.common.CommonOptionKeys;
|
||||
import io.bisq.common.UserThread;
|
||||
|
@ -11,16 +13,14 @@ import io.bisq.common.app.Version;
|
|||
import io.bisq.common.crypto.LimitedKeyStrengthException;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.app.AppOptionKeys;
|
||||
import io.bisq.core.app.BisqEnvironment;
|
||||
import io.bisq.core.app.*;
|
||||
import io.bisq.core.arbitration.ArbitratorManager;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
import io.bisq.core.btc.wallet.WalletService;
|
||||
import io.bisq.core.dao.DaoOptionKeys;
|
||||
import io.bisq.core.offer.OfferBookService;
|
||||
import io.bisq.core.offer.OpenOfferManager;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.network.p2p.P2PService;
|
||||
import io.bisq.network.p2p.P2PServiceListener;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
@ -40,8 +40,8 @@ public class Api {
|
|||
private final OpenOfferManager openOfferManager;
|
||||
//private final WalletService walletService;
|
||||
private final ApiModule apiModule;
|
||||
private final AppSetup appSetup;
|
||||
private final User user;
|
||||
private final P2PService p2pService;
|
||||
|
||||
public static void setEnvironment(Environment env) {
|
||||
Api.env = env;
|
||||
|
@ -83,49 +83,14 @@ public class Api {
|
|||
apiModule = new ApiModule(env);
|
||||
injector = Guice.createInjector(apiModule);
|
||||
Version.setBaseCryptoNetworkId(injector.getInstance(BisqEnvironment.class).getBaseCurrencyNetwork().ordinal());
|
||||
p2pService = injector.getInstance(P2PService.class);
|
||||
offerBookService = injector.getInstance(OfferBookService.class);
|
||||
//walletService = injector.getInstance(WalletService.class);
|
||||
user = injector.getInstance(User.class);
|
||||
openOfferManager = injector.getInstance(OpenOfferManager.class);
|
||||
|
||||
p2pService.start(new P2PServiceListener() {
|
||||
@Override
|
||||
public void onRequestingDataCompleted() {
|
||||
openOfferManager.onAllServicesInitialized();
|
||||
}
|
||||
appSetup = injector.getInstance(AppSetupWithP2P.class);
|
||||
appSetup.start();
|
||||
|
||||
@Override
|
||||
public void onNoSeedNodeAvailable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoPeersAvailable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBootstrapComplete() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTorNodeReady() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenServicePublished() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetupFailed(Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
try {
|
||||
|
||||
injector.getInstance(DropwizardApplication.class).run("server", "bisq-api.yml");
|
||||
|
|
|
@ -175,17 +175,6 @@ public class BisqApp extends Application {
|
|||
bisqAppModule = new BisqAppModule(bisqEnvironment, primaryStage);
|
||||
injector = Guice.createInjector(bisqAppModule);
|
||||
injector.getInstance(InjectorViewFactory.class).setInjector(injector);
|
||||
if(Boolean.valueOf(bisqEnvironment.getRequiredProperty(AppOptionKeys.ENABLE_API))) {
|
||||
injector.getInstance(DropwizardApplication.class).run("server", "bisq-api.yml");
|
||||
}
|
||||
/*
|
||||
PrintWriter out = new PrintWriter(new File("grapher.dot"), "UTF-8");
|
||||
Injector injector = Guice.createInjector(new GraphvizModule());
|
||||
GraphvizGrapher grapher = injector.getInstance(GraphvizGrapher.class);
|
||||
grapher.setOut(out);
|
||||
grapher.setRankdir("TB");
|
||||
grapher.graph(injector);
|
||||
*/
|
||||
|
||||
// All classes which are persisting objects need to be added here
|
||||
// Maintain order!
|
||||
|
@ -226,6 +215,10 @@ public class BisqApp extends Application {
|
|||
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
|
||||
});
|
||||
|
||||
if(Boolean.valueOf(bisqEnvironment.getRequiredProperty(AppOptionKeys.ENABLE_API))) {
|
||||
injector.getInstance(DropwizardApplication.class).run("server", "bisq-api.yml");
|
||||
}
|
||||
|
||||
// load the main view and create the main scene
|
||||
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
|
||||
mainView = (MainView) viewLoader.load(MainView.class);
|
||||
|
|
Loading…
Add table
Reference in a new issue