Stochastic broadcasting delay.
[novacoin.git] / src / net.h
index 3c140fe..8d223ad 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -60,6 +60,9 @@ enum
     LOCAL_MAX
 };
 
+
+bool IsPeerAddrLocalGood(CNode *pnode);
+void AdvertiseLocal(CNode *pnode);
 void SetLimited(enum Network net, bool fLimited = true);
 bool IsLimited(enum Network net);
 bool IsLimited(const CNetAddr& addr);
@@ -112,12 +115,16 @@ enum threadId
     THREAD_MINTER,
     THREAD_SCRIPTCHECK,
     THREAD_NTP,
+    THREAD_IPCOLLECTOR,
 
     THREAD_MAX
 };
 
 extern bool fClient;
 extern bool fDiscover;
+extern bool fNoListen;
+
+extern bool fDiscover;
 extern uint64_t nLocalServices;
 extern uint64_t nLocalHostNonce;
 extern CAddress addrSeenByPeer;
@@ -215,6 +222,9 @@ public:
     bool fGetAddr;
     std::set<uint256> setKnown;
     uint256 hashCheckpointKnown; // ppcoin: known sent sync-checkpoint
+    int64_t nNextAddrSend;
+    int64_t nNextLocalAddrSend;
+    int64_t nNextInvSend;
 
     // inventory based relay
     mruset<CInv> setInventoryKnown;
@@ -235,9 +245,9 @@ public:
         nHeaderStart = -1;
         nMessageStart = std::numeric_limits<uint32_t>::max();
         addr = addrIn;
-        addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
+        addrName = addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn;
         nVersion = 0;
-        strSubVer = "";
+        strSubVer.clear();
         fOneShot = false;
         fClient = false; // set by version message
         fInbound = fInboundIn;
@@ -250,6 +260,9 @@ public:
         pindexLastGetBlocksBegin = 0;
         hashLastGetBlocksEnd = 0;
         nStartingHeight = -1;
+        nNextLocalAddrSend = 0;
+        nNextAddrSend = 0;
+        nNextInvSend = 0;
         fStartSync = false;
         fGetAddr = false;
         nMisbehavior = 0;
@@ -265,8 +278,7 @@ public:
     {
         if (hSocket != INVALID_SOCKET)
         {
-            closesocket(hSocket);
-            hSocket = INVALID_SOCKET;
+            CloseSocket(hSocket);
         }
     }
 
@@ -684,4 +696,7 @@ void RelayTransaction(const CTransaction& tx, const uint256& hash);
 void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss);
 
 
+/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */
+int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds);
+
 #endif