Skip to content

Commit 7f740ae

Browse files
authored
allow to start without komodo.conf for KMD (#642)
* introduce DEFAULT_TXINDEX (true) as a part of constrain constant values to a single location in code * allow to start without komodo.conf for KMD No komodo.conf file is OK
1 parent e40cd54 commit 7f740ae

File tree

6 files changed

+7
-28
lines changed

6 files changed

+7
-28
lines changed

src/bitcoind.cpp

-18
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,6 @@ bool AppInit(int argc, char* argv[])
149149
try
150150
{
151151
ReadConfigFile(mapArgs, mapMultiArgs);
152-
} catch (const missing_zcash_conf& e) {
153-
fprintf(stderr,
154-
(_("Before starting komodod, you need to create a configuration file:\n"
155-
"%s\n"
156-
"It can be completely empty! That indicates you are happy with the default\n"
157-
"configuration of komodod. But requiring a configuration file to start ensures\n"
158-
"that komodod won't accidentally compromise your privacy if there was a default\n"
159-
"option you needed to change.\n"
160-
"\n"
161-
"You can look at the example configuration file for suggestions of default\n"
162-
"options that you may want to change. It should be in one of these locations,\n"
163-
"depending on how you installed Komodo:\n") +
164-
_("- Source code: %s\n"
165-
"- .deb package: %s\n")).c_str(),
166-
GetConfigFile().string().c_str(),
167-
"contrib/debian/examples/komodo.conf",
168-
"/usr/share/doc/komodo/examples/komodo.conf");
169-
return false;
170152
} catch (const std::exception& e) {
171153
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
172154
return false;

src/init.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ std::string HelpMessage(HelpMessageMode mode)
412412
#if !defined(WIN32)
413413
strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)"));
414414
#endif
415-
strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), 0));
415+
strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX));
416416
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));
417417
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));
418418
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
958958
}
959959
KOMODO_LOADINGBLOCKS = false;
960960
// Check for changed -txindex state
961-
if (fTxIndex != GetBoolArg("-txindex", true)) {
961+
if (fTxIndex != GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
962962
strLoadError = _("You need to rebuild the database using -reindex to change -txindex");
963963
return false;
964964
}
@@ -1196,7 +1196,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
11961196
// if using block pruning, then disable txindex
11971197
// also disable the wallet (for now, until SPV support is implemented in wallet)
11981198
if (GetArg("-prune", 0)) {
1199-
if (GetBoolArg("-txindex", true))
1199+
if (GetBoolArg("-txindex", DEFAULT_TXINDEX))
12001200
return InitError(_("Prune mode is incompatible with -txindex."));
12011201
#ifdef ENABLE_WALLET
12021202
if (!GetBoolArg("-disablewallet", false)) {
@@ -1715,7 +1715,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
17151715
// enable 3/4 of the cache if addressindex and/or spentindex is enabled
17161716
nBlockTreeDBCache = nTotalCache * 3 / 4;
17171717
} else {
1718-
if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false)) {
1718+
if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
17191719
nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB
17201720
}
17211721
}

src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6621,7 +6621,7 @@ bool InitBlockIndex()
66216621
if ( pblocktree != 0 )
66226622
{
66236623
// Use the provided setting for -txindex in the new database
6624-
fTxIndex = GetBoolArg("-txindex", true);
6624+
fTxIndex = GetBoolArg("-txindex", DEFAULT_TXINDEX);
66256625
pblocktree->WriteFlag("txindex", fTxIndex);
66266626
// Use the provided setting for -addressindex in the new database
66276627
fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX);

src/main.h

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
122122
/** Default NSPV support enabled */
123123
static const bool DEFAULT_NSPV_PROCESSING = false;
124124

125+
static const bool DEFAULT_TXINDEX = true;
125126
//static const bool DEFAULT_ADDRESSINDEX = false;
126127
//static const bool DEFAULT_SPENTINDEX = false;
127128
#define DEFAULT_ADDRESSINDEX (GetArg("-ac_cc",0) != 0 || GetArg("-ac_ccactivate",0) != 0)

src/util.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
743743

744744
boost::filesystem::ifstream streamConfig(GetConfigFile());
745745
if (!streamConfig.good())
746-
throw missing_zcash_conf();
746+
return; // No komodo.conf file is OK
747747
set<string> setOptions;
748748
setOptions.insert("*");
749749

src/util.h

-4
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ boost::filesystem::path GetConfigFile();
178178
boost::filesystem::path GetPidFile();
179179
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
180180
#endif
181-
class missing_zcash_conf : public std::runtime_error {
182-
public:
183-
missing_zcash_conf() : std::runtime_error("Missing komodo.conf") { }
184-
};
185181
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
186182
#ifdef _WIN32
187183
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);

0 commit comments

Comments
 (0)