From a2352f27f814ec299a25b4c45d3fc33eda6db0cf Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Fri, 18 Oct 2024 18:53:42 +0200 Subject: [PATCH] GLEEC_OLD: exception to fix following the notarizations (#82) * GLEEC_OLD: exception to fix following the notarizations * timeshifting transient verb --------- Co-authored-by: smk762 --- src/chainparams.cpp | 3 +++ src/komodo_utils.cpp | 11 +++++++++++ src/qt/komodoapp.cpp | 8 +++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index b86528a1..49838cc0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -951,6 +951,9 @@ const CChainParams::CCheckpointData GetACCheckPoints() // Check for GLEEC chain with old and new parameters if (chainName.ToString() == "GLEEC") { if (ASSETCHAINS_SUPPLY == 210000000 && ASSETCHAINS_STAKED == 100) { /* old GLEEC */ + ClearDatadirCache(); + chainName = assetchain("GLEEC_OLD"); /* exception to fix following notarizations, + we shouldn't do things like that! */ return checkpointDataGLEECOld; } return checkpointDataDefault; // TODO: return new checkpoints, when we will have enough data diff --git a/src/komodo_utils.cpp b/src/komodo_utils.cpp index b631ee38..c469f698 100644 --- a/src/komodo_utils.cpp +++ b/src/komodo_utils.cpp @@ -1056,6 +1056,15 @@ void komodo_args(char *argv0) uint16_t nonz=0; // keep track of # CCs enabled int32_t extralen = 0; + // prevent starting old GLEEC chain without datadir specified + if (GetArg("-ac_name","") == "GLEEC" && GetArg("-ac_supply",10) == 210000000 && GetArg("-ac_staked",0) == 100) { + if (mapArgs.count("-datadir") == 0) { + const std::string strOldGLEECStartUpError = "It's mandatory to launch old GLEEC chain with -datadir specified!"; + std::cerr << strOldGLEECStartUpError << std::endl; + throw std::runtime_error(strOldGLEECStartUpError); + } + } + const std::string ntz_dest_path = GetArg("-notary", ""); IS_KOMODO_NOTARY = ntz_dest_path == "" ? 0 : 1; @@ -1567,6 +1576,7 @@ void komodo_args(char *argv0) else ASSETCHAINS_P2PPORT = tmpport; + // TODO: if daemon launched with -datadir, but it's not created, the loop below will be endless loop (!) char* dirname = nullptr; while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) { @@ -1724,6 +1734,7 @@ void komodo_args(char *argv0) CCENABLE(EVAL_DICE); CCENABLE(EVAL_ORACLES); } + } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); diff --git a/src/qt/komodoapp.cpp b/src/qt/komodoapp.cpp index a56e2753..a6aa7957 100644 --- a/src/qt/komodoapp.cpp +++ b/src/qt/komodoapp.cpp @@ -707,7 +707,13 @@ int main(int argc, char *argv[]) } void komodo_args(char *argv0); - komodo_args(argv[0]); + try { + komodo_args(argv[0]); + } catch (const std::exception& e) { + QMessageBox::critical(0, QObject::tr(PACKAGE_NAME), + QObject::tr("Error: %1").arg(e.what())); + return EXIT_FAILURE; + } void chainparams_commandline(); chainparams_commandline();