diff --git a/seednode/src/main/java/bisq/seednode/SeedNode.java b/seednode/src/main/java/bisq/seednode/SeedNode.java index 25aff60348..8f4d6458f9 100644 --- a/seednode/src/main/java/bisq/seednode/SeedNode.java +++ b/seednode/src/main/java/bisq/seednode/SeedNode.java @@ -29,29 +29,28 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.name.Names; -import lombok.Setter; import lombok.extern.slf4j.Slf4j; @Slf4j public class SeedNode { - @Setter - private Injector injector; - private AppSetup appSetup; - private GetInventoryRequestHandler getInventoryRequestHandler; - private SeedNodeReportingService seedNodeReportingService; + private final AppSetup appSetup; + private final GetInventoryRequestHandler getInventoryRequestHandler; + private final SeedNodeReportingService seedNodeReportingService; + private final boolean useSeedNodeReportingService; - public SeedNode() { + public SeedNode(Injector injector) { + appSetup = injector.getInstance(AppSetupWithP2PAndDAO.class); + getInventoryRequestHandler = injector.getInstance(GetInventoryRequestHandler.class); + seedNodeReportingService = injector.getInstance(SeedNodeReportingService.class); + + String seedNodeReportingServerUrl = injector.getInstance(Key.get(String.class, Names.named(Config.SEED_NODE_REPORTING_SERVER_URL))); + useSeedNodeReportingService = seedNodeReportingServerUrl != null && !seedNodeReportingServerUrl.trim().isEmpty(); } public void startApplication() { - appSetup = injector.getInstance(AppSetupWithP2PAndDAO.class); appSetup.start(); - - getInventoryRequestHandler = injector.getInstance(GetInventoryRequestHandler.class); - - String seedNodeReportingServerUrl = injector.getInstance(Key.get(String.class, Names.named(Config.SEED_NODE_REPORTING_SERVER_URL))); - if (seedNodeReportingServerUrl != null && !seedNodeReportingServerUrl.trim().isEmpty()) { - seedNodeReportingService = injector.getInstance(SeedNodeReportingService.class); + if (useSeedNodeReportingService) { + seedNodeReportingService.initialize(); } } diff --git a/seednode/src/main/java/bisq/seednode/SeedNodeMain.java b/seednode/src/main/java/bisq/seednode/SeedNodeMain.java index f7c329d3a1..a564a93692 100644 --- a/seednode/src/main/java/bisq/seednode/SeedNodeMain.java +++ b/seednode/src/main/java/bisq/seednode/SeedNodeMain.java @@ -63,13 +63,11 @@ public class SeedNodeMain extends ExecutableForAppWithP2p { new SeedNodeMain().execute(args); } - private final SeedNode seedNode; + private SeedNode seedNode; private Timer checkConnectionLossTimer; public SeedNodeMain() { super("Bisq Seednode", "bisq-seednode", "bisq_seednode", Version.VERSION); - - seedNode = new SeedNode(); } @Override @@ -107,7 +105,7 @@ public class SeedNodeMain extends ExecutableForAppWithP2p { protected void applyInjector() { super.applyInjector(); - seedNode.setInjector(injector); + seedNode = new SeedNode(injector); } @Override diff --git a/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java b/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java index 27b7bdae74..3533b41feb 100644 --- a/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java +++ b/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java @@ -87,6 +87,7 @@ public class SeedNodeReportingService { private final static long HEART_BEAT_DELAY_SEC = TimeUnit.MINUTES.toSeconds(1); private final P2PService p2PService; + private final DaoFacade daoFacade; private final NetworkNode networkNode; private final PeerManager peerManager; private final P2PDataStorage p2PDataStorage; @@ -94,13 +95,14 @@ public class SeedNodeReportingService { private final DaoStateMonitoringService daoStateMonitoringService; private final ProposalStateMonitoringService proposalStateMonitoringService; private final BlindVoteStateMonitoringService blindVoteStateMonitoringService; + private final RequestDataManager requestDataManager; + private final FullNodeNetworkService fullNodeNetworkService; private final int maxConnections; private final String seedNodeReportingServerUrl; private final DaoStateListener daoStateListener; private final HttpClient httpClient; private final ExecutorService executor; - private final Timer heartBeatTimer; - private Timer dataReportTimer; + private Timer heartBeatTimer, dataReportTimer; @Inject public SeedNodeReportingService(P2PService p2PService, @@ -117,6 +119,7 @@ public class SeedNodeReportingService { @Named(Config.MAX_CONNECTIONS) int maxConnections, @Named(Config.SEED_NODE_REPORTING_SERVER_URL) String seedNodeReportingServerUrl) { this.p2PService = p2PService; + this.daoFacade = daoFacade; this.networkNode = networkNode; this.peerManager = peerManager; this.p2PDataStorage = p2PDataStorage; @@ -124,6 +127,8 @@ public class SeedNodeReportingService { this.daoStateMonitoringService = daoStateMonitoringService; this.proposalStateMonitoringService = proposalStateMonitoringService; this.blindVoteStateMonitoringService = blindVoteStateMonitoringService; + this.requestDataManager = requestDataManager; + this.fullNodeNetworkService = fullNodeNetworkService; this.maxConnections = maxConnections; this.seedNodeReportingServerUrl = seedNodeReportingServerUrl; @@ -132,8 +137,6 @@ public class SeedNodeReportingService { executor = Utilities.getThreadPoolExecutor("SeedNodeReportingService", 20, 40, 100, 8 * 60); httpClient = HttpClient.newBuilder().executor(executor).build(); - heartBeatTimer = UserThread.runPeriodically(this::sendHeartBeat, HEART_BEAT_DELAY_SEC); - daoStateListener = new DaoStateListener() { @Override public void onParseBlockChainComplete() { @@ -152,6 +155,11 @@ public class SeedNodeReportingService { }); } }; + } + + public void initialize() { + heartBeatTimer = UserThread.runPeriodically(this::sendHeartBeat, HEART_BEAT_DELAY_SEC); + daoFacade.addBsqStateListener(daoStateListener); p2PService.getNetworkNode().addMessageListener((networkEnvelope, connection) -> {