log low-level network messages only when fDebug is set
[novacoin.git] / src / net.h
index 66f3949..a8356ea 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -17,7 +17,6 @@
 #include "protocol.h"
 
 class CAddrDB;
-class CInv;
 class CRequestTracker;
 class CNode;
 class CBlockIndex;
@@ -52,85 +51,6 @@ enum
     MSG_BLOCK,
 };
 
-static const char* ppszTypeName[] =
-{
-    "ERROR",
-    "tx",
-    "block",
-};
-
-class CInv
-{
-public:
-    int type;
-    uint256 hash;
-
-    CInv()
-    {
-        type = 0;
-        hash = 0;
-    }
-
-    CInv(int typeIn, const uint256& hashIn)
-    {
-        type = typeIn;
-        hash = hashIn;
-    }
-
-    CInv(const std::string& strType, const uint256& hashIn)
-    {
-        int i;
-        for (i = 1; i < ARRAYLEN(ppszTypeName); i++)
-        {
-            if (strType == ppszTypeName[i])
-            {
-                type = i;
-                break;
-            }
-        }
-        if (i == ARRAYLEN(ppszTypeName))
-            throw std::out_of_range(strprintf("CInv::CInv(string, uint256) : unknown type '%s'", strType.c_str()));
-        hash = hashIn;
-    }
-
-    IMPLEMENT_SERIALIZE
-    (
-        READWRITE(type);
-        READWRITE(hash);
-    )
-
-    friend inline bool operator<(const CInv& a, const CInv& b)
-    {
-        return (a.type < b.type || (a.type == b.type && a.hash < b.hash));
-    }
-
-    bool IsKnownType() const
-    {
-        return (type >= 1 && type < ARRAYLEN(ppszTypeName));
-    }
-
-    const char* GetCommand() const
-    {
-        if (!IsKnownType())
-            throw std::out_of_range(strprintf("CInv::GetCommand() : type=%d unknown type", type));
-        return ppszTypeName[type];
-    }
-
-    std::string ToString() const
-    {
-        return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,20).c_str());
-    }
-
-    void print() const
-    {
-        printf("CInv(%s)\n", ToString().c_str());
-    }
-};
-
-
-
-
-
 class CRequestTracker
 {
 public:
@@ -362,9 +282,10 @@ public:
         nHeaderStart = vSend.size();
         vSend << CMessageHeader(pszCommand, 0);
         nMessageStart = vSend.size();
-        if (fDebug)
+        if (fDebug) {
             printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
-        printf("sending: %s ", pszCommand);
+            printf("sending: %s ", pszCommand);
+        }
     }
 
     void AbortMessage()
@@ -404,8 +325,10 @@ public:
             memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum));
         }
 
-        printf("(%d bytes) ", nSize);
-        printf("\n");
+        if (fDebug) {
+            printf("(%d bytes) ", nSize);
+            printf("\n");
+        }
 
         nHeaderStart = -1;
         nMessageStart = -1;