From 86c44682da2a791dbf3d71d91d3f7ad160d0372c Mon Sep 17 00:00:00 2001 From: neodiX Date: Thu, 8 Aug 2024 12:11:52 +0200 Subject: [PATCH] new [with-validators-N] parameter (where N must in range of 1..6) allows in nogui mode to add up to 6 additional validators on start. pooling rate of node status reduced to 10 seconds. --- CHANGELOG.md | 5 ++- README.md | 2 +- src/main/java/org/ton/actions/MyLocalTon.java | 4 +- src/main/java/org/ton/main/App.java | 38 +++++++++++++++++++ 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8336c1..e1d56c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### Changes in this release -- Update TON binaries as of v2024.06 mainnet -- Update TON binaries as of v2024.06 testnet \ No newline at end of file +- new [with-validators-N] parameter (where N must in range of 1..6) allows in nogui mode to add up to 6 additional + validators on start. +- pooling rate of node status reduced to 10 seconds. \ No newline at end of file diff --git a/README.md b/README.md index 9ab0ab4..d8b271b 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msv ## MyLocalTon usage -`java -jar MyLocalTon-x86-64.jar [nogui] [ton-http-api] [explorer] [ip.addr.xxx.xxx] [test-binaries] [debug]` +`java -jar MyLocalTon-x86-64.jar [nogui] [ton-http-api] [explorer] [ip.addr.xxx.xxx] [test-binaries] [with-validators-N] [debug]` for ARM64 architecture use: diff --git a/src/main/java/org/ton/actions/MyLocalTon.java b/src/main/java/org/ton/actions/MyLocalTon.java index a0bb0ee..9d9be13 100644 --- a/src/main/java/org/ton/actions/MyLocalTon.java +++ b/src/main/java/org/ton/actions/MyLocalTon.java @@ -223,7 +223,7 @@ public void runNodesStatusMonitor() { } }); } - }, 0L, 15L, TimeUnit.SECONDS); + }, 0L, 10L, TimeUnit.SECONDS); } public static final class AtomicBigInteger { @@ -1765,7 +1765,7 @@ public void createFullnode(Node node, boolean enableLiteServer, boolean start) t } return; } - log.info("creating new fullnode {}", node.getNodeName()); + log.info("creating new {}", node.getNodeName()); node.extractBinaries(); ValidatorEngine validatorEngine = new ValidatorEngine(); diff --git a/src/main/java/org/ton/main/App.java b/src/main/java/org/ton/main/App.java index 1329f9d..d928e58 100644 --- a/src/main/java/org/ton/main/App.java +++ b/src/main/java/org/ton/main/App.java @@ -9,12 +9,14 @@ import javafx.stage.StageStyle; import javafx.stage.WindowEvent; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.tuple.Pair; import org.ton.actions.MyLocalTon; import org.ton.db.DbPool; import org.ton.executors.dhtserver.DhtServer; import org.ton.executors.validatorengine.ValidatorEngine; import org.ton.executors.validatorengine.ValidatorEngineExecutor; +import org.ton.java.smartcontract.types.WalletVersion; import org.ton.settings.MyLocalTonSettings; import org.ton.settings.Node; import org.ton.ui.controllers.MainController; @@ -23,6 +25,7 @@ import org.ton.utils.MyLocalTonUtils; import java.awt.*; +import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -213,6 +216,41 @@ public static void main(MyLocalTonSettings settings, MyLocalTon myLocalTon, Stri myLocalTon.runValidationMonitor(); + if (!Arrays.asList(args).isEmpty()) { + for (String arg : args) { + if (arg.contains("with-validators-")) { + int i = Integer.parseInt(arg.replace("with-validators-", "")); + if ((i <= 0) || (i > 6)) { + log.error("Wrong number of validators. Allowed values 1..6. No validators will be added."); + break; + } + log.info("adding {} validators", i); + + for (int j = 2; j <= i + 1; j++) { + Node node = settings.getNodeByName("node" + j); + if (settings.getActiveNodes().contains(node.getNodeName())) { + log.info(node.getNodeName() + " already added"); + } else { + + //creating additional validator node + log.info("creating validator {}", node.getNodeName()); + + //delete unfinished or failed node creation + FileUtils.deleteQuietly(new File(MyLocalTonSettings.MY_APP_DIR + File.separator + node.getNodeName())); + + MyLocalTon.getInstance().createFullnode(node, true, true); + + settings.getActiveNodes().add(node.getNodeName()); + MyLocalTon.getInstance().saveSettingsToGson(); + + log.info("Creating new validator controlling smart-contract (wallet) for node {}", node.getNodeName()); + MyLocalTon.getInstance().createWalletEntity(node, null, WalletVersion.V3R2, -1L, settings.getWalletSettings().getDefaultSubWalletId(), node.getInitialValidatorWalletAmount(), true); + } + } + } + } + } + mainController.addValidatorBtn.setDisable(false); } } \ No newline at end of file