changeset 3076:1d80ca635c32 draft

Merge pull request #1458 from jgarzik/tracenet Introduce -tracenet option, thereby quieting some redundant debug messages
author Jeff Garzik <jgarzik@exmulti.com>
date Fri, 22 Jun 2012 10:13:31 -0700
parents d0225da3ddce (current diff) 38c57be55a4d (diff)
children 5e859bcae53b 1e1f730a0adc 1b310a63d338
files src/init.cpp src/main.cpp src/util.h
diffstat 5 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -358,6 +358,13 @@
     // ********************************************************* Step 3: parameter-to-internal-flags
 
     fDebug = GetBoolArg("-debug");
+
+    // -debug implies fDebug*
+    if (fDebug)
+        fDebugNet = true;
+    else
+        fDebugNet = GetBoolArg("-debugnet");
+
     bitdb.SetDetach(GetBoolArg("-detachdb", false));
 
 #if !defined(WIN32) && !defined(QT_GUI)
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3151,7 +3151,8 @@
             const CInv& inv = (*pto->mapAskFor.begin()).second;
             if (!AlreadyHave(txdb, inv))
             {
-                printf("sending getdata: %s\n", inv.ToString().c_str());
+                if (fDebugNet)
+                    printf("sending getdata: %s\n", inv.ToString().c_str());
                 vGetData.push_back(inv);
                 if (vGetData.size() >= 1000)
                 {
--- a/src/net.h
+++ b/src/net.h
@@ -296,7 +296,8 @@
         // We're using mapAskFor as a priority queue,
         // the key is the earliest time the request can be sent
         int64& nRequestTime = mapAlreadyAskedFor[inv];
-        printf("askfor %s   %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);
+        if (fDebugNet)
+            printf("askfor %s   %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);
 
         // Make sure not to reuse time indexes to keep things in the same order
         int64 nNow = (GetTime() - 1) * 1000000;
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -58,6 +58,7 @@
 map<string, string> mapArgs;
 map<string, vector<string> > mapMultiArgs;
 bool fDebug = false;
+bool fDebugNet = false;
 bool fPrintToConsole = false;
 bool fPrintToDebugger = false;
 bool fRequestShutdown = false;
--- a/src/util.h
+++ b/src/util.h
@@ -105,6 +105,7 @@
 extern std::map<std::string, std::string> mapArgs;
 extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
 extern bool fDebug;
+extern bool fDebugNet;
 extern bool fPrintToConsole;
 extern bool fPrintToDebugger;
 extern bool fRequestShutdown;