From ae611a696b9e4ea07de18728c2d977b679d4ba47 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Tue, 12 Nov 2024 23:53:03 +0100 Subject: [PATCH 1/2] introduce DEFAULT_TXINDEX (true) as a part of constrain constant values to a single location in code --- src/init.cpp | 8 ++++---- src/main.cpp | 2 +- src/main.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index b2f07a2d1e2..941c59496ae 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -412,7 +412,7 @@ std::string HelpMessage(HelpMessageMode mode) #if !defined(WIN32) strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)")); #endif - strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), 0)); + strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX)); strUsage += HelpMessageOpt("-addressindex", strprintf(_("Maintain a full address index, used to query for the balance, txids and unspent outputs for addresses (default: %u)"), DEFAULT_ADDRESSINDEX)); strUsage += HelpMessageOpt("-timestampindex", strprintf(_("Maintain a timestamp index for block hashes, used to query blocks hashes by a range of timestamps (default: %u)"), DEFAULT_TIMESTAMPINDEX)); strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX)); @@ -958,7 +958,7 @@ bool AttemptDatabaseOpen(size_t nBlockTreeDBCache, bool dbCompression, size_t db } KOMODO_LOADINGBLOCKS = false; // Check for changed -txindex state - if (fTxIndex != GetBoolArg("-txindex", true)) { + if (fTxIndex != GetBoolArg("-txindex", DEFAULT_TXINDEX)) { strLoadError = _("You need to rebuild the database using -reindex to change -txindex"); return false; } @@ -1196,7 +1196,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // if using block pruning, then disable txindex // also disable the wallet (for now, until SPV support is implemented in wallet) if (GetArg("-prune", 0)) { - if (GetBoolArg("-txindex", true)) + if (GetBoolArg("-txindex", DEFAULT_TXINDEX)) return InitError(_("Prune mode is incompatible with -txindex.")); #ifdef ENABLE_WALLET if (!GetBoolArg("-disablewallet", false)) { @@ -1715,7 +1715,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // enable 3/4 of the cache if addressindex and/or spentindex is enabled nBlockTreeDBCache = nTotalCache * 3 / 4; } else { - if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false)) { + if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", DEFAULT_TXINDEX)) { nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB } } diff --git a/src/main.cpp b/src/main.cpp index e93f65528c4..d3104363683 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6621,7 +6621,7 @@ bool InitBlockIndex() if ( pblocktree != 0 ) { // Use the provided setting for -txindex in the new database - fTxIndex = GetBoolArg("-txindex", true); + fTxIndex = GetBoolArg("-txindex", DEFAULT_TXINDEX); pblocktree->WriteFlag("txindex", fTxIndex); // Use the provided setting for -addressindex in the new database fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX); diff --git a/src/main.h b/src/main.h index 3444058259e..2f479ccc28e 100644 --- a/src/main.h +++ b/src/main.h @@ -122,6 +122,7 @@ static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60; /** Default NSPV support enabled */ static const bool DEFAULT_NSPV_PROCESSING = false; +static const bool DEFAULT_TXINDEX = true; //static const bool DEFAULT_ADDRESSINDEX = false; //static const bool DEFAULT_SPENTINDEX = false; #define DEFAULT_ADDRESSINDEX (GetArg("-ac_cc",0) != 0 || GetArg("-ac_ccactivate",0) != 0) From 6d18504acf9d49dea81036eb79c22e4eb70eae03 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Wed, 13 Nov 2024 00:02:01 +0100 Subject: [PATCH 2/2] allow to start without komodo.conf for KMD No komodo.conf file is OK --- src/bitcoind.cpp | 18 ------------------ src/util.cpp | 2 +- src/util.h | 4 ---- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 23b6ab6e1a7..df37d40c1c5 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -149,24 +149,6 @@ bool AppInit(int argc, char* argv[]) try { ReadConfigFile(mapArgs, mapMultiArgs); - } catch (const missing_zcash_conf& e) { - fprintf(stderr, - (_("Before starting komodod, you need to create a configuration file:\n" - "%s\n" - "It can be completely empty! That indicates you are happy with the default\n" - "configuration of komodod. But requiring a configuration file to start ensures\n" - "that komodod won't accidentally compromise your privacy if there was a default\n" - "option you needed to change.\n" - "\n" - "You can look at the example configuration file for suggestions of default\n" - "options that you may want to change. It should be in one of these locations,\n" - "depending on how you installed Komodo:\n") + - _("- Source code: %s\n" - "- .deb package: %s\n")).c_str(), - GetConfigFile().string().c_str(), - "contrib/debian/examples/komodo.conf", - "/usr/share/doc/komodo/examples/komodo.conf"); - return false; } catch (const std::exception& e) { fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; diff --git a/src/util.cpp b/src/util.cpp index 15a5ce6b1a2..8f85d4c4090 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -743,7 +743,7 @@ void ReadConfigFile(map& mapSettingsRet, boost::filesystem::ifstream streamConfig(GetConfigFile()); if (!streamConfig.good()) - throw missing_zcash_conf(); + return; // No komodo.conf file is OK set setOptions; setOptions.insert("*"); diff --git a/src/util.h b/src/util.h index bc4e31f9768..8456f12ca74 100644 --- a/src/util.h +++ b/src/util.h @@ -178,10 +178,6 @@ boost::filesystem::path GetConfigFile(); boost::filesystem::path GetPidFile(); void CreatePidFile(const boost::filesystem::path &path, pid_t pid); #endif -class missing_zcash_conf : public std::runtime_error { -public: - missing_zcash_conf() : std::runtime_error("Missing komodo.conf") { } -}; void ReadConfigFile(std::map& mapSettingsRet, std::map >& mapMultiSettingsRet); #ifdef _WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);