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 211e1e2..0e64985 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-crypto, wallet-encrypt,\n"); 118 printf(" /selftest=wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt,\n");
@@ -191,6 +193,54 @@ static void ParseStartupArguments(int argc, char* argv[])
191 if (arg(argc,argv,"/debug") || arg(argc,argv,"-debug")) 193 if (arg(argc,argv,"/debug") || arg(argc,argv,"-debug"))
192 fDebug = true; 194 fDebug = true;
193 195
196 // /debugrelay -- everything /debug shows, plus the per-message firehose
197 // ("relay" and "nostrdiscovery" categories: sending: tx, Relaying wtx,
198 // raw CBlock dumps, per-peer discovery lines). That traffic was ~90% of
199 // a 13-hour production debug.log (issue #35), so plain /debug leaves it
200 // off; the message text itself is unchanged for anyone grepping it.
201 if (arg(argc,argv,"/debugrelay") || arg(argc,argv,"-debugrelay"))
202 {
203 fDebug = true;
204 fDebugRelay = true;
205 }
206
207 // /maxdebugfilesize=N -- roll debug.log to debug.log.old once it passes
208 // N MB, checked on each write. Default is 1024 (see util.cpp); 0 turns
209 // the check off and leaves rotation entirely to logrotate.
210 string strMaxDebugSize = argval2(argc, argv, "/maxdebugfilesize", "-maxdebugfilesize");
211 if (!strMaxDebugSize.empty())
212 {
213 // Parsed with atoi64() before, which is strtoll() with the endptr
214 // thrown away: it returns 0 for anything it cannot read, so
215 // /maxdebugfilesize=1G and =1024MB both came out as 0 -- "never
216 // roll", identical to asking for that on purpose, with nothing said
217 // to the operator. The old code also multiplied without a range
218 // check, so a big enough N wrapped to a negative cap, which the roll
219 // reads as "off" too. Every rejection is now reported and leaves the
220 // default in place; the value is a plain count of MB, no suffix.
221 const char* psz = strMaxDebugSize.c_str();
222 char* pszEnd = NULL;
223 errno = 0;
224 int64 nMB = strtoll(psz, &pszEnd, 10);
225 // INT64_MAX, without depending on which limits header this tree pulls in.
226 const int64 nMaxMB = (int64)((~(uint64)0) >> 1) / (1024 * 1024);
227 const char* pszWhy = NULL;
228 if (pszEnd == psz)
229 pszWhy = "not a number";
230 else if (*pszEnd != '\0')
231 pszWhy = "trailing characters -- the value is a count of MB, with no unit suffix";
232 else if (errno == ERANGE || nMB < 0)
233 pszWhy = "not a size in MB";
234 else if (nMB > nMaxMB)
235 pszWhy = "larger than a file size can be";
236 if (pszWhy)
237 fprintf(stderr, "Ignoring /maxdebugfilesize=%s: %s (keeping %lld MB)\n",
238 strMaxDebugSize.c_str(), pszWhy,
239 (long long)(nMaxDebugFileSize / 1024 / 1024));
240 else
241 nMaxDebugFileSize = nMB * 1024 * 1024;
242 }
243
194 if (arg(argc,argv,"/gen") || arg(argc,argv,"-gen")) 244 if (arg(argc,argv,"/gen") || arg(argc,argv,"-gen"))
195 { 245 {
196 fGenerateBitcoins = 1; 246 fGenerateBitcoins = 1;