upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r--src/main_gui.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 25cde1c..dd001c8 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -111,6 +111,8 @@ static void PrintUsage()
111 printf(" /help, -help, --help, /?\n"); 111 printf(" /help, -help, --help, /?\n");
112 printf(" /datadir=PATH\n"); 112 printf(" /datadir=PATH\n");
113 printf(" /debug\n"); 113 printf(" /debug\n");
114 printf(" /debugrelay (/debug plus per-message relay chatter and block dumps)\n");
115 printf(" /maxdebugfilesize=N (roll debug.log at N MB, default 1024; 0 = never)\n");
114 printf(" /gen\n"); 116 printf(" /gen\n");
115 printf(" /nogui or /daemon\n"); 117 printf(" /nogui or /daemon\n");
116 printf(" /selftest=wallet-keypool, wallet-hd, wallet-format, wallet-storage-sanity,\n"); 118 printf(" /selftest=wallet-keypool, wallet-hd, wallet-format, wallet-storage-sanity,\n");
@@ -215,6 +217,54 @@ static void ParseStartupArguments(int argc, char* argv[])
215 if (arg(argc,argv,"/debug") || arg(argc,argv,"-debug")) 217 if (arg(argc,argv,"/debug") || arg(argc,argv,"-debug"))
216 fDebug = true; 218 fDebug = true;
217 219
220 // /debugrelay -- everything /debug shows, plus the per-message firehose
221 // ("relay" and "nostrdiscovery" categories: sending: tx, Relaying wtx,
222 // raw CBlock dumps, per-peer discovery lines). That traffic was ~90% of
223 // a 13-hour production debug.log (issue #35), so plain /debug leaves it
224 // off; the message text itself is unchanged for anyone grepping it.
225 if (arg(argc,argv,"/debugrelay") || arg(argc,argv,"-debugrelay"))
226 {
227 fDebug = true;
228 fDebugRelay = true;
229 }
230
231 // /maxdebugfilesize=N -- roll debug.log to debug.log.old once it passes
232 // N MB, checked on each write. Default is 1024 (see util.cpp); 0 turns
233 // the check off and leaves rotation entirely to logrotate.
234 string strMaxDebugSize = argval2(argc, argv, "/maxdebugfilesize", "-maxdebugfilesize");
235 if (!strMaxDebugSize.empty())
236 {
237 // Parsed with atoi64() before, which is strtoll() with the endptr
238 // thrown away: it returns 0 for anything it cannot read, so
239 // /maxdebugfilesize=1G and =1024MB both came out as 0 -- "never
240 // roll", identical to asking for that on purpose, with nothing said
241 // to the operator. The old code also multiplied without a range
242 // check, so a big enough N wrapped to a negative cap, which the roll
243 // reads as "off" too. Every rejection is now reported and leaves the
244 // default in place; the value is a plain count of MB, no suffix.
245 const char* psz = strMaxDebugSize.c_str();
246 char* pszEnd = NULL;
247 errno = 0;
248 int64 nMB = strtoll(psz, &pszEnd, 10);
249 // INT64_MAX, without depending on which limits header this tree pulls in.
250 const int64 nMaxMB = (int64)((~(uint64)0) >> 1) / (1024 * 1024);
251 const char* pszWhy = NULL;
252 if (pszEnd == psz)
253 pszWhy = "not a number";
254 else if (*pszEnd != '\0')
255 pszWhy = "trailing characters -- the value is a count of MB, with no unit suffix";
256 else if (errno == ERANGE || nMB < 0)
257 pszWhy = "not a size in MB";
258 else if (nMB > nMaxMB)
259 pszWhy = "larger than a file size can be";
260 if (pszWhy)
261 fprintf(stderr, "Ignoring /maxdebugfilesize=%s: %s (keeping %lld MB)\n",
262 strMaxDebugSize.c_str(), pszWhy,
263 (long long)(nMaxDebugFileSize / 1024 / 1024));
264 else
265 nMaxDebugFileSize = nMB * 1024 * 1024;
266 }
267
218 if (arg(argc,argv,"/gen") || arg(argc,argv,"-gen")) 268 if (arg(argc,argv,"/gen") || arg(argc,argv,"-gen"))
219 { 269 {
220 fGenerateBitcoins = 1; 270 fGenerateBitcoins = 1;