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 3552a465340..2c2992f6904 100644 --- a/core/src/main/java/bisq/core/app/misc/ExecutableForAppWithP2p.java +++ b/core/src/main/java/bisq/core/app/misc/ExecutableForAppWithP2p.java @@ -149,13 +149,7 @@ public void startShutDownInterval(GracefulShutDownHandler gracefulShutDownHandle seedNodeAddresses.sort(Comparator.comparing(NodeAddress::getFullAddress)); NodeAddress myAddress = injector.getInstance(P2PService.class).getNetworkNode().getNodeAddress(); - int myIndex = -1; - for (int i = 0; i < seedNodeAddresses.size(); i++) { - if (seedNodeAddresses.get(i).equals(myAddress)) { - myIndex = i; - break; - } - } + int myIndex = seedNodeAddresses.indexOf(myAddress); if (myIndex == -1) { log.warn("We did not find our node address in the seed nodes repository. " + @@ -184,11 +178,13 @@ public void startShutDownInterval(GracefulShutDownHandler gracefulShutDownHandle // triggered multiple times after a restart while being in the same hour. It can be that we miss our target // hour during that delay but that is not considered problematic, the seed would just restart a bit longer than // 24 hours. - int target = myIndex; UserThread.runAfter(() -> { // We check every hour if we are in the target hour. UserThread.runPeriodically(() -> { int currentHour = ZonedDateTime.ofInstant(Instant.now(), ZoneId.of("UTC")).getHour(); + + // distribute evenly between 0-23 + long target = Math.round(24d / seedNodeAddresses.size() * myIndex) % 24; if (currentHour == target) { log.warn("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" + "Shut down node at hour {} (UTC time is {})" +