X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fnet.h;h=8d223aded5a386ce5d401dac6f9535b1f72ca892;hp=a94621002376ebd4d76583505fc471913e6fdb24;hb=c95d66bd55a225326e81dce15d347f04b1d71d67;hpb=e1b880f73f13657d82309aa550697336dfcb7ec9 diff --git a/src/net.h b/src/net.h index a946210..8d223ad 100644 --- a/src/net.h +++ b/src/net.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_NET_H #define BITCOIN_NET_H +#include #include #ifndef Q_MOC_RUN #include @@ -18,7 +19,6 @@ #include "mruset.h" #include "netbase.h" -#include "protocol.h" #include "addrman.h" #include "hash.h" @@ -27,6 +27,8 @@ class CNode; class CBlockIndex; extern int nBestHeight; +const uint16_t nSocksDefault = 9050; +const uint16_t nPortZero = 0; inline uint64_t ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } @@ -51,7 +53,6 @@ enum LOCAL_NONE, // unknown LOCAL_IF, // address a local interface listens on LOCAL_BIND, // address explicit bound to - LOCAL_UPNP, // address reported by UPnP LOCAL_IRC, // address reported by IRC (deprecated) LOCAL_HTTP, // address reported by whatismyip.com and similar LOCAL_MANUAL, // address explicitly specified (-externalip=) @@ -59,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); @@ -75,7 +79,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL); enum { MSG_TX = 1, - MSG_BLOCK, + MSG_BLOCK }; class CRequestTracker @@ -104,20 +108,23 @@ enum threadId THREAD_OPENCONNECTIONS, THREAD_MESSAGEHANDLER, THREAD_RPCLISTENER, - THREAD_UPNP, THREAD_DNSSEED, THREAD_ADDEDCONNECTIONS, THREAD_DUMPADDRESS, THREAD_RPCHANDLER, THREAD_MINTER, THREAD_SCRIPTCHECK, + THREAD_NTP, + THREAD_IPCOLLECTOR, THREAD_MAX }; extern bool fClient; extern bool fDiscover; -extern bool fUseUPnP; +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 setKnown; uint256 hashCheckpointKnown; // ppcoin: known sent sync-checkpoint + int64_t nNextAddrSend; + int64_t nNextLocalAddrSend; + int64_t nNextInvSend; // inventory based relay mruset setInventoryKnown; @@ -233,11 +243,11 @@ public: nLastSendEmpty = GetTime(); nTimeConnected = GetTime(); nHeaderStart = -1; - nMessageStart = -1; + nMessageStart = std::numeric_limits::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); } } @@ -375,7 +387,7 @@ public: return; vSend.resize(nHeaderStart); nHeaderStart = -1; - nMessageStart = -1; + nMessageStart = std::numeric_limits::max(); LEAVE_CRITICAL_SECTION(cs_vSend); if (fDebug) @@ -410,7 +422,7 @@ public: } nHeaderStart = -1; - nMessageStart = -1; + nMessageStart = std::numeric_limits::max(); LEAVE_CRITICAL_SECTION(cs_vSend); } @@ -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