mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Instead of delaying the shutdown in case of a resync we delay the startup. This has the benefit that nodes cannot connect to the seed node while having inconsistant dao data.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
aa9d3a3123
commit
94a9c8ac01
@ -24,5 +24,6 @@ public enum CookieKey {
|
||||
STAGE_W,
|
||||
STAGE_H,
|
||||
TRADE_STAT_CHART_USE_USD,
|
||||
CLEAN_TOR_DIR_AT_RESTART
|
||||
CLEAN_TOR_DIR_AT_RESTART,
|
||||
DELAY_STARTUP
|
||||
}
|
||||
|
@ -115,6 +115,18 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
|
||||
super.startApplication();
|
||||
|
||||
Cookie cookie = injector.getInstance(User.class).getCookie();
|
||||
if (cookie.getAsOptionalBoolean(CookieKey.DELAY_STARTUP).orElse(false)) {
|
||||
cookie.remove(CookieKey.DELAY_STARTUP);
|
||||
try {
|
||||
// We create a deterministic delay per seed to avoid that all seeds start up at the
|
||||
// same time in case of a reorg.
|
||||
long delay = getMyIndex() * TimeUnit.SECONDS.toMillis(30);
|
||||
Thread.sleep(delay);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
cookie.getAsOptionalBoolean(CookieKey.CLEAN_TOR_DIR_AT_RESTART).ifPresent(cleanTorDirAtRestart -> {
|
||||
if (cleanTorDirAtRestart) {
|
||||
injector.getInstance(TorSetup.class).cleanupTorFiles(() ->
|
||||
@ -133,10 +145,12 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
|
||||
});
|
||||
|
||||
injector.getInstance(DaoStateSnapshotService.class).setResyncDaoStateFromResourcesHandler(
|
||||
// We shut down with a deterministic delay per seed to avoid that all seeds shut down at the
|
||||
// same time in case of a reorg. We use 30 sec. as distance delay between the seeds to be on the
|
||||
// safe side. We have 12 seeds so that's 6 minutes.
|
||||
() -> UserThread.runAfter(this::gracefulShutDown, 1 + (getMyIndex() * 30L))
|
||||
// We set DELAY_STARTUP and shut down. At start up we delay with a deterministic delay to avoid
|
||||
// that all seeds get restarted at the same time.
|
||||
() -> {
|
||||
injector.getInstance(User.class).getCookie().putAsBoolean(CookieKey.DELAY_STARTUP, true);
|
||||
shutDown(this);
|
||||
}
|
||||
);
|
||||
|
||||
injector.getInstance(P2PService.class).addP2PServiceListener(new P2PServiceListener() {
|
||||
|
Loading…
Reference in New Issue
Block a user