From bb40dcde6557667ebc67e23a3599d98ec2e96a4c Mon Sep 17 00:00:00 2001 From: kennycud Date: Thu, 7 Nov 2024 11:51:56 -0800 Subject: [PATCH 1/4] Reduced connection error to a warning. Removed unnecessary return value. --- .../org/qortal/repository/hsqldb/HSQLDBCacheUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBCacheUtils.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBCacheUtils.java index ef7288dc..81fcb3c5 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBCacheUtils.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBCacheUtils.java @@ -12,6 +12,7 @@ import org.qortal.data.arbitrary.ArbitraryResourceStatus; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.SQLNonTransientConnectionException; import java.sql.Statement; import java.time.format.DateTimeFormatter; import java.util.AbstractMap; @@ -355,9 +356,7 @@ public class HSQLDBCacheUtils { * * @return the data cache */ - public static ArbitraryResourceCache startCaching(int priorityRequested, int frequency, HSQLDBRepository respository) { - - final ArbitraryResourceCache cache = ArbitraryResourceCache.getInstance(); + public static void startCaching(int priorityRequested, int frequency, HSQLDBRepository respository) { // ensure priority is in between 1-10 final int priority = Math.max(0, Math.min(10, priorityRequested)); @@ -388,8 +387,6 @@ public class HSQLDBCacheUtils { // delay 1 second timer.scheduleAtFixedRate(task, 1000, frequency * 1000); - - return cache; } /** @@ -418,6 +415,9 @@ public class HSQLDBCacheUtils { fillNamepMap(cache.getLevelByName(), repository); } + catch (SQLNonTransientConnectionException e ) { + LOGGER.warn("Connection problems. Retry later."); + } catch (Exception e) { LOGGER.error(e.getMessage(), e); } From a0b4853518ca2502c2fb0d24ea8b15cb67f95ebb Mon Sep 17 00:00:00 2001 From: AlphaX-Reloaded Date: Fri, 8 Nov 2024 09:59:18 +0100 Subject: [PATCH 2/4] Moved auto restart node as feature in settings --- src/main/java/org/qortal/ApplyRestart.java | 19 ++++++---- .../org/qortal/controller/Controller.java | 36 ++++++++++--------- .../java/org/qortal/settings/Settings.java | 6 ++++ 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/qortal/ApplyRestart.java b/src/main/java/org/qortal/ApplyRestart.java index a2d4588d..9488488c 100644 --- a/src/main/java/org/qortal/ApplyRestart.java +++ b/src/main/java/org/qortal/ApplyRestart.java @@ -43,7 +43,7 @@ public class ApplyRestart { private static final String JAVA_TOOL_OPTIONS_NAME = "JAVA_TOOL_OPTIONS"; private static final String JAVA_TOOL_OPTIONS_VALUE = ""; - private static final long CHECK_INTERVAL = 10 * 1000L; // ms + private static final long CHECK_INTERVAL = 30 * 1000L; // ms private static final int MAX_ATTEMPTS = 12; public static void main(String[] args) { @@ -56,7 +56,7 @@ public class ApplyRestart { else Settings.getInstance(); - LOGGER.info("Applying restart..."); + LOGGER.info("Applying restart this can take up to 5 minutes..."); // Shutdown node using API if (!shutdownNode()) @@ -64,19 +64,19 @@ public class ApplyRestart { try { // Give some time for shutdown - TimeUnit.SECONDS.sleep(30); + TimeUnit.SECONDS.sleep(60); // Remove blockchain lock if exist ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock(); if (blockchainLock.isLocked()) blockchainLock.unlock(); - // Remove blockchain lock file if exist + // Remove blockchain lock file if still exist TimeUnit.SECONDS.sleep(60); deleteLock(); // Restart node - TimeUnit.SECONDS.sleep(30); + TimeUnit.SECONDS.sleep(15); restartNode(args); LOGGER.info("Restarting..."); @@ -117,10 +117,17 @@ public class ApplyRestart { String response = ApiRequest.perform(baseUri + "admin/stop", params); if (response == null) { // No response - consider node shut down + try { + TimeUnit.SECONDS.sleep(30); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + if (apiKeyNewlyGenerated) { // API key was newly generated for restarting node, so we need to remove it ApplyRestart.removeGeneratedApiKey(); } + return true; } @@ -171,7 +178,7 @@ public class ApplyRestart { LOGGER.debug("Lockfile is: {}", lockFile); FileUtils.forceDelete(FileUtils.getFile(lockFile)); } catch (IOException e) { - LOGGER.error("Error deleting blockchain lock file: {}", e.getMessage()); + LOGGER.debug("Error deleting blockchain lock file: {}", e.getMessage()); } } diff --git a/src/main/java/org/qortal/controller/Controller.java b/src/main/java/org/qortal/controller/Controller.java index bdbb2ab9..30aa9a54 100644 --- a/src/main/java/org/qortal/controller/Controller.java +++ b/src/main/java/org/qortal/controller/Controller.java @@ -568,26 +568,28 @@ 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 if we have enough connected peers - Timer checkConnectedPeers = new Timer(); + if (Settings.getInstance().isAutoRestartEnabled()) { + // Check every 10 minutes if we have enough connected peers + Timer checkConnectedPeers = new Timer(); - 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); + 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); + }, 10*60*1000, 10*60*1000); + } // Check every 10 minutes to see if the block minter is running Timer checkBlockMinter = new Timer(); diff --git a/src/main/java/org/qortal/settings/Settings.java b/src/main/java/org/qortal/settings/Settings.java index 8395af60..91dee4ad 100644 --- a/src/main/java/org/qortal/settings/Settings.java +++ b/src/main/java/org/qortal/settings/Settings.java @@ -114,6 +114,8 @@ public class Settings { /** Whether we check, fetch and install auto-updates */ private boolean autoUpdateEnabled = true; + /** Whether we check, restart node without connected peers */ + private boolean autoRestartEnabled = false; /** How long between repository backups (ms), or 0 if disabled. */ private long repositoryBackupInterval = 0; // ms /** Whether to show a notification when we backup repository. */ @@ -913,6 +915,10 @@ public class Settings { return this.autoUpdateEnabled; } + public boolean isAutoRestartEnabled() { + return this.autoRestartEnabled; + } + public String[] getAutoUpdateRepos() { return this.autoUpdateRepos; } From 5e1ad82738b3e28e452adfe25bc777fa2091ef9b Mon Sep 17 00:00:00 2001 From: crowetic Date: Fri, 8 Nov 2024 08:30:16 -0800 Subject: [PATCH 3/4] Merged alpha default restart settings and kenny logging changes, made a couple small default settings changes for thread priority. --- src/main/java/org/qortal/settings/Settings.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/qortal/settings/Settings.java b/src/main/java/org/qortal/settings/Settings.java index db59bd2e..39510678 100644 --- a/src/main/java/org/qortal/settings/Settings.java +++ b/src/main/java/org/qortal/settings/Settings.java @@ -408,7 +408,7 @@ public class Settings { * The thread priority (1 is lowest, 10 is highest) of the threads used for network peer connections. This is the * main thread connecting to a peer in the network. */ - private int networkThreadPriority = 5; + private int networkThreadPriority = 7; /** * The Handshake Thread Priority @@ -416,14 +416,14 @@ public class Settings { * The thread priority (1 i slowest, 10 is highest) of the threads used for peer handshake messaging. This is a * secondary thread to exchange status messaging to a peer in the network. */ - private int handshakeThreadPriority = 5; + private int handshakeThreadPriority = 7; /** * Pruning Thread Priority * * The thread priority (1 is lowest, 10 is highest) of the threads used for database pruning and trimming. */ - private int pruningThreadPriority = 1; + private int pruningThreadPriority = 2; /** * Sychronizer Thread Priority From 2ee5bc5b3550baff09f0839475e0dffbd5ea96b4 Mon Sep 17 00:00:00 2001 From: crowetic Date: Fri, 8 Nov 2024 08:40:55 -0800 Subject: [PATCH 4/4] added README changes to build a single PR for new release candidate --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dd9ad60..fa4d1213 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ -# Qortal Project - Official Repo +# Qortal Project - Qortal Core - Primary Repository +The Qortal Core is the blockchain and node component of the overall project. It contains the primary API, and ability to make calls to create transactions, and interact with the Qortal Blockchain Network. + +In order to run the Qortal Core, a machine with java 11+ installed is required. Minimum RAM specs will vary depending on settings, but as low as 4GB of RAM should be acceptable in most scenarios. + +Qortal is a complete infrastructure platform with a blockchain backend, it is capable of indefinite web and application hosting with no continual fees, replacement of DNS and centralized name systems and communications systems, and is the foundation of the next generation digital infrastructure of the world. Qortal is unique in nearly every way, and was written from scratch to address as many concerns from both the existing 'blockchain space' and the 'typical internet' as possible, while maintaining a system that is easy to use and able to run on 'any' computer. + +Qortal contains extensive functionality geared toward complete decentralization of the digital world. Removal of 'middlemen' of any kind from all transactions, and ability to publish websites and applications that require no continual fees, on a name that is truly owned by the account that registered it, or purchased it from another. A single name on Qortal is capable of being both a namespace and a 'username'. That single name can have an application, website, public and private data, communications, authentication, the namespace itself and more, which can subsequently be sold to anyone else without the need to change any type of 'hosting' or DNS entries that do not exist, email that doesn't exist, etc. Maintaining the same functionality as those replaced features of web 2.0. + +Over time Qortal has progressed into a fully featured environment catering to any and all types of people and organizations, and will continue to advance as time goes on. Brining more features, capability, device support, and availale replacements for web2.0. Ultimately building a new, completely user-controlled digital world without limits. + +Qortal has no owner, no company on top of it, and is completely community built, run, and funded. A community-established and run group of developers known as the 'dev-group' or Qortal Development Group, make group_approval based decisions for the project's future. If you are a developer interested in assisting with the project, you meay reach out to the Qortal Development Group in any of the available Qortal community locations. Either on the Qortal network itself, or on one of the temporary centralized social media locations. + +Building the future one block at a time. Welcome to Qortal. + +# Building the Qortal Core from Source ## Build / run @@ -10,3 +25,21 @@ - Run JAR in same working directory as *settings.json*: `java -jar target/qortal-1.0.jar` - Wrap in shell script, add JVM flags, redirection, backgrounding, etc. as necessary. - Or use supplied example shell script: *start.sh* + +# Using a pre-built Qortal 'jar' binary + +If you would prefer to utilize a released version of Qortal, you may do so by downloading one of the available releases from the releases page, that are also linked on https://qortal.org and https://qortal.dev. + +# Learning Q-App Development + +https://qortal.dev contains dev documentation for building JS/React (and other client-side languages) applications or 'Q-Apps' on Qortal. Q-Apps are published on Registered Qortal Names, and aside from a single Name Registration fee, and a fraction of QORT for a publish transaction, require zero continual costs. These applications get more redundant with each new access from a new Qortal Node, making your application faster for the next user to download, and stronger as time goes on. Q-Apps live indefinitely in the history of the blockchain-secured Qortal Data Network (QDN). + +# How to learn more + +If the project interests you, you may learn more from the various web2 and QDN based websites focused on introductory information. + +https://qortal.org - primary internet presence +https://qortal.dev - secondary and development focused website with links to many new developments and documentation +https://wiki.qortal.org - community built and managed wiki with detailed information regarding the project + +links to telegram and discord communities are at the top of https://qortal.org as well.