Merge pull request #7180 from HenrikJannsen/2_further-refactorings-and-improvements

Further refactorings and improvements [B]
This commit is contained in:
Alejandro García 2024-06-28 21:54:35 +00:00 committed by GitHub
commit 9920595399
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 52 additions and 144 deletions

View File

@ -21,4 +21,9 @@ import bisq.common.handlers.ResultHandler;
public interface GracefulShutDownHandler { public interface GracefulShutDownHandler {
void gracefulShutDown(ResultHandler resultHandler); void gracefulShutDown(ResultHandler resultHandler);
default void gracefulShutDown() {
gracefulShutDown(() -> {
});
}
} }

View File

@ -33,6 +33,7 @@ import bisq.network.p2p.P2PService;
import bisq.network.p2p.seed.SeedNodeRepository; import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.UserThread; import bisq.common.UserThread;
import bisq.common.app.AppModule;
import bisq.common.app.DevEnv; import bisq.common.app.DevEnv;
import bisq.common.config.Config; import bisq.common.config.Config;
import bisq.common.file.JsonFileManager; import bisq.common.file.JsonFileManager;
@ -73,12 +74,22 @@ public abstract class ExecutableForAppWithP2p extends BisqExecutable {
UserThread.setExecutor(executorService); UserThread.setExecutor(executorService);
} }
@Override
protected AppModule getModule() {
return new ModuleForAppWithP2p(config);
}
@Override @Override
protected void startApplication() { protected void startApplication() {
// Pin that as it is used in PaymentMethods and verification in TradeStatistics // Pin that as it is used in PaymentMethods and verification in TradeStatistics
tradeLimits = injector.getInstance(TradeLimits.class); tradeLimits = injector.getInstance(TradeLimits.class);
} }
@Override
protected void launchApplication() {
onApplicationLaunched();
}
@Override @Override
public void onSetupComplete() { public void onSetupComplete() {
log.info("onSetupComplete"); log.info("onSetupComplete");

View File

@ -95,7 +95,6 @@ import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.FilteredList;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -731,8 +730,8 @@ public class DaoFacade implements DaoSetupService {
daoStateStorageService.resyncDaoStateFromGenesis(resultHandler); daoStateStorageService.resyncDaoStateFromGenesis(resultHandler);
} }
public void removeAndBackupAllDaoData(File storageDir) throws IOException { public void removeAndBackupAllDaoData() throws IOException {
daoStateStorageService.removeAndBackupAllDaoData(storageDir); daoStateStorageService.removeAndBackupAllDaoData();
} }
public boolean isMyRole(Role role) { public boolean isMyRole(Role role) {

View File

@ -34,11 +34,9 @@ import bisq.common.config.Config;
import bisq.common.util.GcUtil; import bisq.common.util.GcUtil;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
@ -68,7 +66,6 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
private final BsqWalletService bsqWalletService; private final BsqWalletService bsqWalletService;
private final Preferences preferences; private final Preferences preferences;
private final Config config; private final Config config;
private final File storageDir;
private protobuf.DaoState daoStateCandidate; private protobuf.DaoState daoStateCandidate;
private LinkedList<DaoStateHash> hashChainCandidate = new LinkedList<>(); private LinkedList<DaoStateHash> hashChainCandidate = new LinkedList<>();
@ -95,8 +92,7 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
WalletsSetup walletsSetup, WalletsSetup walletsSetup,
BsqWalletService bsqWalletService, BsqWalletService bsqWalletService,
Preferences preferences, Preferences preferences,
Config config, Config config) {
@Named(Config.STORAGE_DIR) File storageDir) {
this.daoStateService = daoStateService; this.daoStateService = daoStateService;
this.genesisTxInfo = genesisTxInfo; this.genesisTxInfo = genesisTxInfo;
this.daoStateStorageService = daoStateStorageService; this.daoStateStorageService = daoStateStorageService;
@ -105,7 +101,6 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
this.bsqWalletService = bsqWalletService; this.bsqWalletService = bsqWalletService;
this.preferences = preferences; this.preferences = preferences;
this.config = config; this.config = config;
this.storageDir = storageDir;
} }
@ -334,7 +329,7 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
return; return;
} }
try { try {
daoStateStorageService.removeAndBackupAllDaoData(storageDir); daoStateStorageService.removeAndBackupAllDaoData();
// the restart handler informs the user of the need to restart bisq (in desktop mode) // the restart handler informs the user of the need to restart bisq (in desktop mode)
if (resyncDaoStateFromResourcesHandler == null) { if (resyncDaoStateFromResourcesHandler == null) {
log.error("resyncDaoStateFromResourcesHandler COULD NOT be called as it has not been initialized yet"); log.error("resyncDaoStateFromResourcesHandler COULD NOT be called as it has not been initialized yet");

View File

@ -351,8 +351,9 @@ public class DaoState implements PersistablePayload {
",\n paramChangeList=" + paramChangeList + ",\n paramChangeList=" + paramChangeList +
",\n evaluatedProposalList=" + evaluatedProposalList + ",\n evaluatedProposalList=" + evaluatedProposalList +
",\n decryptedBallotsWithMeritsList=" + decryptedBallotsWithMeritsList + ",\n decryptedBallotsWithMeritsList=" + decryptedBallotsWithMeritsList +
",\n txCache=" + txCache + /* ",\n txCache=" + txCache +
",\n txOutputsByTxOutputType=" + txOutputsByTxOutputType + ",\n blocksByHeight=" + blocksByHeight +
",\n txOutputsByTxOutputType=" + txOutputsByTxOutputType +*/
"\n}"; "\n}";
} }
} }

View File

@ -204,7 +204,7 @@ public class DaoStateStorageService extends StoreService<DaoStateStore> {
bsqBlocksStorageService.removeBlocksInDirectory(); bsqBlocksStorageService.removeBlocksInDirectory();
} }
public void removeAndBackupAllDaoData(File storageDir) throws IOException { public void removeAndBackupAllDaoData() throws IOException {
// We delete all DAO consensus data and remove the daoState so it will rebuild from latest // We delete all DAO consensus data and remove the daoState so it will rebuild from latest
// resource files. // resource files.
String backupDirName = "out_of_sync_dao_data"; String backupDirName = "out_of_sync_dao_data";

View File

@ -41,7 +41,6 @@ public class DaoStateSnapshotServiceTest {
null, null,
null, null,
null, null,
null,
null); null);
} }

View File

@ -65,8 +65,6 @@ import javafx.collections.transformation.SortedList;
import javafx.util.Callback; import javafx.util.Callback;
import java.io.File;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -83,7 +81,6 @@ public abstract class StateMonitorView<StH extends StateHash,
protected final CycleService cycleService; protected final CycleService cycleService;
protected final PeriodService periodService; protected final PeriodService periodService;
protected final Set<NodeAddress> seedNodeAddresses; protected final Set<NodeAddress> seedNodeAddresses;
private final File storageDir;
protected TextField statusTextField; protected TextField statusTextField;
protected Button resyncFromResourcesButton; protected Button resyncFromResourcesButton;
@ -110,14 +107,12 @@ public abstract class StateMonitorView<StH extends StateHash,
DaoFacade daoFacade, DaoFacade daoFacade,
CycleService cycleService, CycleService cycleService,
PeriodService periodService, PeriodService periodService,
SeedNodeRepository seedNodeRepository, SeedNodeRepository seedNodeRepository) {
File storageDir) {
this.daoStateService = daoStateService; this.daoStateService = daoStateService;
this.daoFacade = daoFacade; this.daoFacade = daoFacade;
this.cycleService = cycleService; this.cycleService = cycleService;
this.periodService = periodService; this.periodService = periodService;
this.seedNodeAddresses = new HashSet<>(seedNodeRepository.getSeedNodeAddresses()); this.seedNodeAddresses = new HashSet<>(seedNodeRepository.getSeedNodeAddresses());
this.storageDir = storageDir;
} }
@Override @Override
@ -286,7 +281,7 @@ public abstract class StateMonitorView<StH extends StateHash,
private void resyncFromResources() { private void resyncFromResources() {
try { try {
daoFacade.removeAndBackupAllDaoData(storageDir); daoFacade.removeAndBackupAllDaoData();
new Popup().attention(Res.get("setting.preferences.dao.resyncFromResources.popup")) new Popup().attention(Res.get("setting.preferences.dao.resyncFromResources.popup"))
.useShutDownButton() .useShutDownButton()
.hideCloseButton() .hideCloseButton()

View File

@ -33,10 +33,7 @@ import bisq.core.locale.Res;
import bisq.network.p2p.seed.SeedNodeRepository; import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.config.Config;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import javafx.scene.control.TableCell; import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
@ -45,8 +42,6 @@ import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.util.Callback; import javafx.util.Callback;
import java.io.File;
import java.util.Comparator; import java.util.Comparator;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -68,9 +63,8 @@ public class BlindVoteStateMonitorView extends StateMonitorView<BlindVoteStateHa
BlindVoteStateMonitoringService blindVoteStateMonitoringService, BlindVoteStateMonitoringService blindVoteStateMonitoringService,
CycleService cycleService, CycleService cycleService,
PeriodService periodService, PeriodService periodService,
SeedNodeRepository seedNodeRepository, SeedNodeRepository seedNodeRepository) {
@Named(Config.STORAGE_DIR) File storageDir) { super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository);
super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository, storageDir);
this.blindVoteStateMonitoringService = blindVoteStateMonitoringService; this.blindVoteStateMonitoringService = blindVoteStateMonitoringService;
} }

View File

@ -35,11 +35,9 @@ import bisq.core.locale.Res;
import bisq.network.p2p.seed.SeedNodeRepository; import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.config.Config;
import bisq.common.util.Utilities; import bisq.common.util.Utilities;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import javafx.scene.control.TableCell; import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
@ -50,8 +48,6 @@ import javafx.collections.ListChangeListener;
import javafx.util.Callback; import javafx.util.Callback;
import java.io.File;
import java.util.Comparator; import java.util.Comparator;
import java.util.Map; import java.util.Map;
import java.util.function.IntSupplier; import java.util.function.IntSupplier;
@ -75,9 +71,8 @@ public class DaoStateMonitorView extends StateMonitorView<DaoStateHash, DaoState
DaoStateMonitoringService daoStateMonitoringService, DaoStateMonitoringService daoStateMonitoringService,
CycleService cycleService, CycleService cycleService,
PeriodService periodService, PeriodService periodService,
SeedNodeRepository seedNodeRepository, SeedNodeRepository seedNodeRepository) {
@Named(Config.STORAGE_DIR) File storageDir) { super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository);
super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository, storageDir);
this.daoStateMonitoringService = daoStateMonitoringService; this.daoStateMonitoringService = daoStateMonitoringService;
} }

View File

@ -33,10 +33,7 @@ import bisq.core.locale.Res;
import bisq.network.p2p.seed.SeedNodeRepository; import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.config.Config;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import javafx.scene.control.TableCell; import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
@ -45,8 +42,6 @@ import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.util.Callback; import javafx.util.Callback;
import java.io.File;
import java.util.Comparator; import java.util.Comparator;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -67,9 +62,8 @@ public class ProposalStateMonitorView extends StateMonitorView<ProposalStateHash
ProposalStateMonitoringService proposalStateMonitoringService, ProposalStateMonitoringService proposalStateMonitoringService,
CycleService cycleService, CycleService cycleService,
PeriodService periodService, PeriodService periodService,
SeedNodeRepository seedNodeRepository, SeedNodeRepository seedNodeRepository) {
@Named(Config.STORAGE_DIR) File storageDir) { super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository);
super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository, storageDir);
this.proposalStateMonitoringService = proposalStateMonitoringService; this.proposalStateMonitoringService = proposalStateMonitoringService;
} }

View File

@ -107,8 +107,6 @@ import javafx.util.Callback;
import javafx.util.Duration; import javafx.util.Duration;
import javafx.util.StringConverter; import javafx.util.StringConverter;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -151,7 +149,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private final FilterManager filterManager; private final FilterManager filterManager;
private final DaoFacade daoFacade; private final DaoFacade daoFacade;
private final boolean isBmFullNodeFromOptions; private final boolean isBmFullNodeFromOptions;
private final File storageDir;
private ListView<FiatCurrency> fiatCurrenciesListView; private ListView<FiatCurrency> fiatCurrenciesListView;
private ComboBox<FiatCurrency> fiatCurrenciesComboBox; private ComboBox<FiatCurrency> fiatCurrenciesComboBox;
@ -198,8 +195,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
@Named(Config.IS_BM_FULL_NODE) boolean isBmFullNodeFromOptions, @Named(Config.IS_BM_FULL_NODE) boolean isBmFullNodeFromOptions,
@Named(Config.RPC_USER) String rpcUser, @Named(Config.RPC_USER) String rpcUser,
@Named(Config.RPC_PASSWORD) String rpcPassword, @Named(Config.RPC_PASSWORD) String rpcPassword,
@Named(Config.RPC_BLOCK_NOTIFICATION_PORT) int rpcBlockNotificationPort, @Named(Config.RPC_BLOCK_NOTIFICATION_PORT) int rpcBlockNotificationPort) {
@Named(Config.STORAGE_DIR) File storageDir) {
super(model); super(model);
this.user = user; this.user = user;
this.burningManAccountingService = burningManAccountingService; this.burningManAccountingService = burningManAccountingService;
@ -211,7 +207,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
this.filterManager = filterManager; this.filterManager = filterManager;
this.daoFacade = daoFacade; this.daoFacade = daoFacade;
this.isBmFullNodeFromOptions = isBmFullNodeFromOptions; this.isBmFullNodeFromOptions = isBmFullNodeFromOptions;
this.storageDir = storageDir;
daoFullModeFromOptionsSet = config.fullDaoNodeOptionSetExplicitly && daoFullModeFromOptionsSet = config.fullDaoNodeOptionSetExplicitly &&
rpcUser != null && !rpcUser.isEmpty() && rpcUser != null && !rpcUser.isEmpty() &&
rpcPassword != null && !rpcPassword.isEmpty() && rpcPassword != null && !rpcPassword.isEmpty() &&
@ -1225,7 +1220,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
resyncDaoFromResourcesButton.setOnAction(e -> { resyncDaoFromResourcesButton.setOnAction(e -> {
try { try {
daoFacade.removeAndBackupAllDaoData(storageDir); daoFacade.removeAndBackupAllDaoData();
new Popup().attention(Res.get("setting.preferences.dao.resyncFromResources.popup")) new Popup().attention(Res.get("setting.preferences.dao.resyncFromResources.popup"))
.useShutDownButton() .useShutDownButton()
.hideCloseButton() .hideCloseButton()

View File

@ -22,7 +22,6 @@ import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.app.TorSetup; import bisq.core.app.TorSetup;
import bisq.core.app.misc.AppSetupWithP2PAndDAO; import bisq.core.app.misc.AppSetupWithP2PAndDAO;
import bisq.core.app.misc.ExecutableForAppWithP2p; import bisq.core.app.misc.ExecutableForAppWithP2p;
import bisq.core.app.misc.ModuleForAppWithP2p;
import bisq.core.dao.SignVerifyService; import bisq.core.dao.SignVerifyService;
import bisq.core.dao.governance.bond.reputation.BondedReputationRepository; import bisq.core.dao.governance.bond.reputation.BondedReputationRepository;
import bisq.core.dao.governance.bond.role.BondedRolesRepository; import bisq.core.dao.governance.bond.role.BondedRolesRepository;
@ -39,7 +38,6 @@ import bisq.network.p2p.peers.PeerManager;
import bisq.common.Timer; import bisq.common.Timer;
import bisq.common.UserThread; import bisq.common.UserThread;
import bisq.common.app.AppModule;
import bisq.common.app.Version; import bisq.common.app.Version;
import bisq.common.config.BaseCurrencyNetwork; import bisq.common.config.BaseCurrencyNetwork;
import bisq.common.config.Config; import bisq.common.config.Config;
@ -83,27 +81,11 @@ public class RestApi extends ExecutableForAppWithP2p {
checkMemory(config, this); checkMemory(config, this);
} }
@Override
protected void launchApplication() {
UserThread.execute(() -> {
try {
onApplicationLaunched();
} catch (Exception e) {
e.printStackTrace();
}
});
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// We continue with a series of synchronous execution tasks // We continue with a series of synchronous execution tasks
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected AppModule getModule() {
return new ModuleForAppWithP2p(config);
}
@Override @Override
protected void applyInjector() { protected void applyInjector() {
super.applyInjector(); super.applyInjector();
@ -206,11 +188,6 @@ public class RestApi extends ExecutableForAppWithP2p {
} }
public void gracefulShutDown() {
gracefulShutDown(() -> {
});
}
@Override @Override
public void gracefulShutDown(ResultHandler resultHandler) { public void gracefulShutDown(ResultHandler resultHandler) {
super.gracefulShutDown(resultHandler); super.gracefulShutDown(resultHandler);

View File

@ -19,7 +19,6 @@ package bisq.seednode;
import bisq.core.app.TorSetup; import bisq.core.app.TorSetup;
import bisq.core.app.misc.ExecutableForAppWithP2p; import bisq.core.app.misc.ExecutableForAppWithP2p;
import bisq.core.app.misc.ModuleForAppWithP2p;
import bisq.core.dao.state.DaoStateSnapshotService; import bisq.core.dao.state.DaoStateSnapshotService;
import bisq.core.user.CookieKey; import bisq.core.user.CookieKey;
import bisq.core.user.User; import bisq.core.user.User;
@ -32,9 +31,9 @@ import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.Timer; import bisq.common.Timer;
import bisq.common.UserThread; import bisq.common.UserThread;
import bisq.common.app.AppModule;
import bisq.common.app.Capabilities; import bisq.common.app.Capabilities;
import bisq.common.app.Capability; import bisq.common.app.Capability;
import bisq.common.app.Version;
import bisq.common.config.BaseCurrencyNetwork; import bisq.common.config.BaseCurrencyNetwork;
import bisq.common.config.Config; import bisq.common.config.Config;
import bisq.common.handlers.ResultHandler; import bisq.common.handlers.ResultHandler;
@ -50,17 +49,18 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class SeedNodeMain extends ExecutableForAppWithP2p { public class SeedNodeMain extends ExecutableForAppWithP2p {
private static final long CHECK_CONNECTION_LOSS_SEC = 30; private static final long CHECK_CONNECTION_LOSS_SEC = 30;
private static final String VERSION = "1.9.17";
private SeedNode seedNode; public static void main(String[] args) {
new SeedNodeMain().execute(args);
}
private final SeedNode seedNode;
private Timer checkConnectionLossTime; private Timer checkConnectionLossTime;
public SeedNodeMain() { public SeedNodeMain() {
super("Bisq Seednode", "bisq-seednode", "bisq_seednode", VERSION); super("Bisq Seednode", "bisq-seednode", "bisq_seednode", Version.VERSION);
}
public static void main(String[] args) { seedNode = new SeedNode();
System.out.println("SeedNode.VERSION: " + VERSION);
new SeedNodeMain().execute(args);
} }
@Override @Override
@ -68,7 +68,6 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
super.doExecute(); super.doExecute();
checkMemory(config, this); checkMemory(config, this);
keepRunning(); keepRunning();
} }
@ -77,23 +76,6 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
Capabilities.app.addAll(Capability.SEED_NODE); Capabilities.app.addAll(Capability.SEED_NODE);
} }
@Override
protected void launchApplication() {
UserThread.execute(() -> {
try {
seedNode = new SeedNode();
onApplicationLaunched();
} catch (Exception e) {
e.printStackTrace();
}
});
}
@Override
protected void onApplicationLaunched() {
super.onApplicationLaunched();
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// UncaughtExceptionHandler implementation // UncaughtExceptionHandler implementation
@ -112,11 +94,6 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
// We continue with a series of synchronous execution tasks // We continue with a series of synchronous execution tasks
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected AppModule getModule() {
return new ModuleForAppWithP2p(config);
}
@Override @Override
protected void applyInjector() { protected void applyInjector() {
super.applyInjector(); super.applyInjector();
@ -237,11 +214,6 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
} }
private void gracefulShutDown() {
gracefulShutDown(() -> {
});
}
@Override @Override
public void gracefulShutDown(ResultHandler resultHandler) { public void gracefulShutDown(ResultHandler resultHandler) {
seedNode.shutDown(); seedNode.shutDown();

View File

@ -18,63 +18,39 @@
package bisq.statistics; package bisq.statistics;
import bisq.core.app.misc.ExecutableForAppWithP2p; import bisq.core.app.misc.ExecutableForAppWithP2p;
import bisq.core.app.misc.ModuleForAppWithP2p;
import bisq.common.UserThread; import bisq.common.app.Version;
import bisq.common.app.AppModule;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class StatisticsMain extends ExecutableForAppWithP2p { public class StatisticsMain extends ExecutableForAppWithP2p {
private static final String VERSION = "1.0.1";
private Statistics statistics;
public StatisticsMain() {
super("Bisq Statsnode", "bisq-statistics", "bisq_statistics", VERSION);
}
public static void main(String[] args) { public static void main(String[] args) {
log.info("Statistics.VERSION: " + VERSION);
new StatisticsMain().execute(args); new StatisticsMain().execute(args);
} }
private final Statistics statistics;
public StatisticsMain() {
super("Bisq Statsnode", "bisq-statistics", "bisq_statistics", Version.VERSION);
statistics = new Statistics();
}
@Override @Override
protected void doExecute() { protected void doExecute() {
super.doExecute(); super.doExecute();
checkMemory(config, this); checkMemory(config, this);
keepRunning(); keepRunning();
} }
@Override
protected void launchApplication() {
UserThread.execute(() -> {
try {
statistics = new Statistics();
UserThread.execute(this::onApplicationLaunched);
} catch (Exception e) {
e.printStackTrace();
}
});
}
@Override
protected void onApplicationLaunched() {
super.onApplicationLaunched();
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// We continue with a series of synchronous execution tasks // We continue with a series of synchronous execution tasks
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected AppModule getModule() {
return new ModuleForAppWithP2p(config);
}
@Override @Override
protected void applyInjector() { protected void applyInjector() {
super.applyInjector(); super.applyInjector();