diff --git a/src/init.cpp b/src/init.cpp index 4ab7bdc42..21c32a6d6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -358,6 +358,13 @@ bool AppInit2() // ********************************************************* 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) diff --git a/src/main.cpp b/src/main.cpp index 6765ed5f0..a49d2a06b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3151,7 +3151,8 @@ bool SendMessages(CNode* pto, bool fSendTrickle) 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) { diff --git a/src/net.h b/src/net.h index c9c965722..f059c7a44 100644 --- a/src/net.h +++ b/src/net.h @@ -296,7 +296,8 @@ public: // 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; diff --git a/src/util.cpp b/src/util.cpp index b07c9c1b7..4b1c1ae11 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -58,6 +58,7 @@ using namespace std; map mapArgs; map > mapMultiArgs; bool fDebug = false; +bool fDebugNet = false; bool fPrintToConsole = false; bool fPrintToDebugger = false; bool fRequestShutdown = false; diff --git a/src/util.h b/src/util.h index c9b2b2f17..21bec68ae 100644 --- a/src/util.h +++ b/src/util.h @@ -105,6 +105,7 @@ inline void Sleep(int64 n) extern std::map mapArgs; extern std::map > mapMultiArgs; extern bool fDebug; +extern bool fDebugNet; extern bool fPrintToConsole; extern bool fPrintToDebugger; extern bool fRequestShutdown;