Better wording for transaction fee notification messages
[novacoin.git] / net.h
diff --git a/net.h b/net.h
index 33c5914..b3bd74d 100644 (file)
--- a/net.h
+++ b/net.h
@@ -24,12 +24,14 @@ enum
 
 bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet);
 bool GetMyExternalIP(unsigned int& ipRet);
-bool AddAddress(CAddress addr);
+bool AddAddress(CAddress addr, int64 nTimePenalty=0);
 void AddressCurrentlyConnected(const CAddress& addr);
 CNode* FindNode(unsigned int ip);
 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(string& strError=REF(string()));
 void StartNode(void* parg);
 bool StopNode();
@@ -139,7 +141,7 @@ public:
     unsigned int ip;
     unsigned short port;
 
-    // disk only
+    // disk and network only
     unsigned int nTime;
 
     // memory only
@@ -186,7 +188,7 @@ public:
         memcpy(pchReserved, pchIPv4, sizeof(pchReserved));
         ip = INADDR_NONE;
         port = GetDefaultPort();
-        nTime = GetAdjustedTime();
+        nTime = 100000000;
         nLastTry = 0;
     }
 
@@ -218,11 +220,12 @@ public:
 
     IMPLEMENT_SERIALIZE
     (
+        if (fRead)
+            const_cast<CAddress*>(this)->Init();
         if (nType & SER_DISK)
-        {
             READWRITE(nVersion);
+        if ((nType & SER_DISK) || (nVersion >= 31402 && !(nType & SER_GETHASH)))
             READWRITE(nTime);
-        }
         READWRITE(nServices);
         READWRITE(FLATDATA(pchReserved)); // for IPv6
         READWRITE(ip);
@@ -415,7 +418,7 @@ public:
     const char* GetCommand() const
     {
         if (!IsKnownType())
-            throw std::out_of_range(strprintf("CInv::GetCommand() : type=% unknown type", type));
+            throw std::out_of_range(strprintf("CInv::GetCommand() : type=%d unknown type", type));
         return ppszTypeName[type];
     }
 
@@ -570,14 +573,9 @@ public:
         fGetAddr = false;
         vfSubscribe.assign(256, false);
 
-        // Push a version message
-        /// when NTP implemented, change to just nTime = GetAdjustedTime()
-        int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
-        CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
-        CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
-        RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
-        PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe,
-                    nLocalHostNonce, string(pszSubVer), nBestHeight);
+        // Be shy and don't send version until we hear
+        if (!fInbound)
+            PushVersion();
     }
 
     ~CNode()
@@ -732,11 +730,17 @@ public:
             AbortMessage();
     }
 
-    const char* GetMessageCommand() const
+
+
+    void PushVersion()
     {
-        if (nHeaderStart == -1)
-            return "";
-        return &vSend[nHeaderStart] + offsetof(CMessageHeader, pchCommand);
+        /// when NTP implemented, change to just nTime = GetAdjustedTime()
+        int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
+        CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
+        CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
+        RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
+        PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe,
+                nLocalHostNonce, string(pszSubVer), nBestHeight);
     }