forked from Qortal/qortal
Adjusted network settings and added reboot
This commit is contained in:
parent
941847dd98
commit
bcf68ea63d
2
pom.xml
2
pom.xml
@ -49,7 +49,7 @@
|
||||
<maven-reproducible-build-plugin.version>0.17</maven-reproducible-build-plugin.version>
|
||||
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
|
||||
<maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
|
||||
<maven-surefire-plugin.version>3.5.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
|
||||
<protobuf.version>3.25.3</protobuf.version>
|
||||
<replacer.version>1.5.3</replacer.version>
|
||||
<simplemagic.version>1.17</simplemagic.version>
|
||||
|
@ -6,6 +6,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
|
||||
import org.qortal.api.ApiKey;
|
||||
import org.qortal.api.ApiRequest;
|
||||
import org.qortal.controller.Controller;
|
||||
import org.qortal.controller.RestartNode;
|
||||
import org.qortal.settings.Settings;
|
||||
|
||||
@ -16,6 +17,8 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.Security;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.qortal.controller.RestartNode.AGENTLIB_JVM_HOLDER_ARG;
|
||||
@ -57,6 +60,18 @@ public class ApplyRestart {
|
||||
if (!shutdownNode())
|
||||
return;
|
||||
|
||||
// Give some time after shutdown
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.error("Unable to restart", e);
|
||||
}
|
||||
|
||||
// Remove blockchain lock if it exist
|
||||
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
|
||||
if (blockchainLock.isLocked())
|
||||
blockchainLock.unlock();
|
||||
|
||||
// Restart node
|
||||
restartNode(args);
|
||||
|
||||
@ -150,9 +165,10 @@ public class ApplyRestart {
|
||||
|
||||
List<String> javaCmd;
|
||||
if (Files.exists(exeLauncher)) {
|
||||
javaCmd = Arrays.asList(exeLauncher.toString());
|
||||
javaCmd = List.of(exeLauncher.toString());
|
||||
} else {
|
||||
javaCmd = new ArrayList<>();
|
||||
|
||||
// Java runtime binary itself
|
||||
javaCmd.add(javaBinary.toString());
|
||||
|
||||
@ -193,4 +209,4 @@ public class ApplyRestart {
|
||||
LOGGER.error(String.format("Failed to restart node (BAD): %s", e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,7 +489,6 @@ public class Controller extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setName("Shutdown hook");
|
||||
|
||||
Controller.getInstance().shutdown();
|
||||
}
|
||||
});
|
||||
@ -569,10 +568,31 @@ public class Controller extends Thread {
|
||||
// If GUI is enabled, we're no longer starting up but actually running now
|
||||
Gui.getInstance().notifyRunning();
|
||||
|
||||
// Check every 10 minutes to see if the block minter is running
|
||||
Timer timer = new Timer();
|
||||
// Check every 10 minutes if we have enough connected peers
|
||||
Timer checkConnectedPeers = new Timer();
|
||||
|
||||
timer.schedule(new TimerTask() {
|
||||
checkConnectedPeers.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Get the connected peers
|
||||
int myConnectedPeers = Network.getInstance().getImmutableHandshakedPeers().size();
|
||||
LOGGER.debug("Node have {} connected peers", myConnectedPeers);
|
||||
if (myConnectedPeers == 0) {
|
||||
// Restart node if we have 0 peers
|
||||
LOGGER.info("Node have no connected peers, restarting node");
|
||||
try {
|
||||
RestartNode.attemptToRestart();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Unable to restart the node", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 10*60*1000, 10*60*1000);
|
||||
|
||||
// Check every 10 minutes to see if the block minter is running
|
||||
Timer checkBlockMinter = new Timer();
|
||||
|
||||
checkBlockMinter.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (blockMinter.isAlive()) {
|
||||
|
@ -53,7 +53,7 @@ public class Network {
|
||||
/**
|
||||
* How long between informational broadcasts to all connected peers, in milliseconds.
|
||||
*/
|
||||
private static final long BROADCAST_INTERVAL = 60 * 1000L; // ms
|
||||
private static final long BROADCAST_INTERVAL = 30 * 1000L; // ms
|
||||
/**
|
||||
* Maximum time since last successful connection for peer info to be propagated, in milliseconds.
|
||||
*/
|
||||
@ -83,12 +83,12 @@ public class Network {
|
||||
"node6.qortalnodes.live", "node7.qortalnodes.live", "node8.qortalnodes.live"
|
||||
};
|
||||
|
||||
private static final long NETWORK_EPC_KEEPALIVE = 10L; // seconds
|
||||
private static final long NETWORK_EPC_KEEPALIVE = 5L; // seconds
|
||||
|
||||
public static final int MAX_SIGNATURES_PER_REPLY = 500;
|
||||
public static final int MAX_BLOCK_SUMMARIES_PER_REPLY = 500;
|
||||
|
||||
private static final long DISCONNECTION_CHECK_INTERVAL = 10 * 1000L; // milliseconds
|
||||
private static final long DISCONNECTION_CHECK_INTERVAL = 20 * 1000L; // milliseconds
|
||||
|
||||
private static final int BROADCAST_CHAIN_TIP_DEPTH = 7; // Just enough to fill a SINGLE TCP packet (~1440 bytes)
|
||||
|
||||
|
@ -197,21 +197,21 @@ public class Settings {
|
||||
/** Target number of outbound connections to peers we should make. */
|
||||
private int minOutboundPeers = 32;
|
||||
/** Maximum number of peer connections we allow. */
|
||||
private int maxPeers = 60;
|
||||
private int maxPeers = 64;
|
||||
/** Number of slots to reserve for short-lived QDN data transfers */
|
||||
private int maxDataPeers = 5;
|
||||
/** Maximum number of threads for network engine. */
|
||||
private int maxNetworkThreadPoolSize = 620;
|
||||
private int maxNetworkThreadPoolSize = 512;
|
||||
/** Maximum number of threads for network proof-of-work compute, used during handshaking. */
|
||||
private int networkPoWComputePoolSize = 2;
|
||||
private int networkPoWComputePoolSize = 4;
|
||||
/** Maximum number of retry attempts if a peer fails to respond with the requested data */
|
||||
private int maxRetries = 2;
|
||||
private int maxRetries = 3;
|
||||
|
||||
/** The number of seconds of no activity before recovery mode begins */
|
||||
public long recoveryModeTimeout = 9999999999999L;
|
||||
|
||||
/** Minimum peer version number required in order to sync with them */
|
||||
private String minPeerVersion = "4.5.2";
|
||||
private String minPeerVersion = "4.6.0";
|
||||
/** Whether to allow connections with peers below minPeerVersion
|
||||
* If true, we won't sync with them but they can still sync with us, and will show in the peers list
|
||||
* If false, sync will be blocked both ways, and they will not appear in the peers list */
|
||||
|
Loading…
Reference in New Issue
Block a user