Update copyrights to 2012 for files modified this year
[novacoin.git] / src / net.h
index 66f3949..52df06f 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -1,5 +1,5 @@
 // Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2011 The Bitcoin developers
+// Copyright (c) 2009-2012 The Bitcoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
 #ifndef BITCOIN_NET_H
@@ -17,7 +17,6 @@
 #include "protocol.h"
 
 class CAddrDB;
-class CInv;
 class CRequestTracker;
 class CNode;
 class CBlockIndex;
@@ -41,7 +40,6 @@ CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
 void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
 bool AnySubscribed(unsigned int nChannel);
 void MapPort(bool fMapPort);
-void DNSAddressSeed();
 bool BindListenPort(std::string& strError=REF(std::string()));
 void StartNode(void* parg);
 bool StopNode();
@@ -52,85 +50,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:
@@ -345,7 +264,9 @@ public:
         // Make sure not to reuse time indexes to keep things in the same order
         int64 nNow = (GetTime() - 1) * 1000000;
         static int64 nLastTime;
-        nLastTime = nNow = std::max(nNow, ++nLastTime);
+        ++nLastTime;
+        nNow = std::max(nNow, nLastTime);
+        nLastTime = nNow;
 
         // Each retry is 2 minutes after the last
         nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow);
@@ -362,9 +283,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()
@@ -375,7 +297,9 @@ public:
         nHeaderStart = -1;
         nMessageStart = -1;
         cs_vSend.Leave();
-        printf("(aborted)\n");
+
+        if (fDebug)
+            printf("(aborted)\n");
     }
 
     void EndMessage()
@@ -404,8 +328,9 @@ public:
             memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum));
         }
 
-        printf("(%d bytes) ", nSize);
-        printf("\n");
+        if (fDebug) {
+            printf("(%d bytes)\n", nSize);
+        }
 
         nHeaderStart = -1;
         nMessageStart = -1;