diff --git a/core/src/main/java/bisq/core/app/misc/ExecutableForAppWithP2p.java b/core/src/main/java/bisq/core/app/misc/ExecutableForAppWithP2p.java index e41b2ddfdb..c573b4dea9 100644 --- a/core/src/main/java/bisq/core/app/misc/ExecutableForAppWithP2p.java +++ b/core/src/main/java/bisq/core/app/misc/ExecutableForAppWithP2p.java @@ -54,6 +54,7 @@ public abstract class ExecutableForAppWithP2p extends BisqExecutable { private volatile boolean stopped; private final long startTime = System.currentTimeMillis(); private TradeLimits tradeLimits; + private AppSetupWithP2PAndDAO appSetupWithP2PAndDAO; public ExecutableForAppWithP2p(String fullName, String scriptName, String appName, String version) { super(fullName, scriptName, appName, version); @@ -71,11 +72,19 @@ public abstract class ExecutableForAppWithP2p extends BisqExecutable { } @Override - protected void startApplication() { + protected void applyInjector() { + super.applyInjector(); + + appSetupWithP2PAndDAO = injector.getInstance(AppSetupWithP2PAndDAO.class); // Pin that as it is used in PaymentMethods and verification in TradeStatistics tradeLimits = injector.getInstance(TradeLimits.class); } + @Override + protected void startApplication() { + appSetupWithP2PAndDAO.start(); + } + @Override protected void launchApplication() { onApplicationLaunched(); diff --git a/restapi/src/main/java/bisq/restapi/RestApi.java b/restapi/src/main/java/bisq/restapi/RestApi.java index 375b5e73cb..ea78e34401 100644 --- a/restapi/src/main/java/bisq/restapi/RestApi.java +++ b/restapi/src/main/java/bisq/restapi/RestApi.java @@ -20,7 +20,6 @@ package bisq.restapi; import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.app.TorSetup; -import bisq.core.app.misc.AppSetupWithP2PAndDAO; import bisq.core.app.misc.ExecutableForAppWithP2p; import bisq.core.dao.SignVerifyService; import bisq.core.dao.governance.bond.reputation.BondedReputationRepository; @@ -107,7 +106,6 @@ public class RestApi extends ExecutableForAppWithP2p { }); injector.getInstance(Preferences.class).setUseFullModeDaoMonitor(false); - injector.getInstance(AppSetupWithP2PAndDAO.class).start(); daoStateService = injector.getInstance(DaoStateService.class); accountAgeWitnessService = injector.getInstance(AccountAgeWitnessService.class); diff --git a/seednode/src/main/java/bisq/seednode/SeedNode.java b/seednode/src/main/java/bisq/seednode/SeedNode.java index 8f4d6458f9..0c0a593f67 100644 --- a/seednode/src/main/java/bisq/seednode/SeedNode.java +++ b/seednode/src/main/java/bisq/seednode/SeedNode.java @@ -19,8 +19,6 @@ package bisq.seednode; import bisq.seednode.reporting.SeedNodeReportingService; -import bisq.core.app.misc.AppSetup; -import bisq.core.app.misc.AppSetupWithP2PAndDAO; import bisq.core.network.p2p.inventory.GetInventoryRequestHandler; import bisq.common.config.Config; @@ -33,13 +31,11 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class SeedNode { - private final AppSetup appSetup; private final GetInventoryRequestHandler getInventoryRequestHandler; private final SeedNodeReportingService seedNodeReportingService; private final boolean useSeedNodeReportingService; public SeedNode(Injector injector) { - appSetup = injector.getInstance(AppSetupWithP2PAndDAO.class); getInventoryRequestHandler = injector.getInstance(GetInventoryRequestHandler.class); seedNodeReportingService = injector.getInstance(SeedNodeReportingService.class); @@ -48,7 +44,6 @@ public class SeedNode { } public void startApplication() { - appSetup.start(); if (useSeedNodeReportingService) { seedNodeReportingService.initialize(); } diff --git a/statsnode/src/main/java/bisq/statistics/Statistics.java b/statsnode/src/main/java/bisq/statistics/Statistics.java index 2177744b82..9b5fbc6d38 100644 --- a/statsnode/src/main/java/bisq/statistics/Statistics.java +++ b/statsnode/src/main/java/bisq/statistics/Statistics.java @@ -17,8 +17,6 @@ package bisq.statistics; -import bisq.core.app.misc.AppSetup; -import bisq.core.app.misc.AppSetupWithP2PAndDAO; import bisq.core.offer.OfferBookService; import bisq.core.provider.price.PriceFeedService; import bisq.core.trade.statistics.TradeStatisticsManager; @@ -28,29 +26,23 @@ import bisq.network.p2p.P2PService; import com.google.inject.Injector; -import lombok.Setter; import lombok.extern.slf4j.Slf4j; @Slf4j public class Statistics { - @Setter - private Injector injector; + private final P2PService p2pService; + private final PriceFeedService priceFeedService; + private final TradeStatisticsManager tradeStatisticsManager; + private final OfferBookService offerBookService; // pin to not get GC'ed - private OfferBookService offerBookService; // pin to not get GC'ed - private PriceFeedService priceFeedService; - private TradeStatisticsManager tradeStatisticsManager; - private P2PService p2pService; - private AppSetup appSetup; - - public Statistics() { + public Statistics(Injector injector) { + p2pService = injector.getInstance(P2PService.class); + priceFeedService = injector.getInstance(PriceFeedService.class); + tradeStatisticsManager = injector.getInstance(TradeStatisticsManager.class); + offerBookService = injector.getInstance(OfferBookService.class); } public void startApplication() { - p2pService = injector.getInstance(P2PService.class); - offerBookService = injector.getInstance(OfferBookService.class); - priceFeedService = injector.getInstance(PriceFeedService.class); - tradeStatisticsManager = injector.getInstance(TradeStatisticsManager.class); - // We need the price feed for market based offers priceFeedService.setCurrencyCode("USD"); p2pService.addP2PServiceListener(new BootstrapListener() { @@ -64,8 +56,5 @@ public class Statistics { tradeStatisticsManager.onAllServicesInitialized(); } }); - - appSetup = injector.getInstance(AppSetupWithP2PAndDAO.class); - appSetup.start(); } } diff --git a/statsnode/src/main/java/bisq/statistics/StatisticsMain.java b/statsnode/src/main/java/bisq/statistics/StatisticsMain.java index 116fec7101..282aa184ed 100644 --- a/statsnode/src/main/java/bisq/statistics/StatisticsMain.java +++ b/statsnode/src/main/java/bisq/statistics/StatisticsMain.java @@ -30,12 +30,10 @@ public class StatisticsMain extends ExecutableForAppWithP2p { new StatisticsMain().execute(args); } - private final Statistics statistics; + private Statistics statistics; public StatisticsMain() { super("Bisq Statsnode", "bisq-statistics", "bisq_statistics", Version.VERSION); - - statistics = new Statistics(); } @Override @@ -54,14 +52,12 @@ public class StatisticsMain extends ExecutableForAppWithP2p { @Override protected void applyInjector() { super.applyInjector(); - - statistics.setInjector(injector); + statistics = new Statistics(injector); } @Override protected void startApplication() { super.startApplication(); - statistics.startApplication(); } }