mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Create SeedNode when injector is available and pass injector to constructor.
Add initialize method to seedNodeReportingService Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
1f83c8e68c
commit
259f869e69
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) -> {
|
||||
|
Loading…
Reference in New Issue
Block a user