X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fnet.h;h=7306d136b63967e40345c63280bf43322dc9c042;hb=92948780909cc9e3349409d6102dbe5adf1d5a10;hp=369d4fd1707fc6959f2ded76036c0bff0376821b;hpb=77a43545b4491b9703d803765da9059d2bdd5aaa;p=novacoin.git diff --git a/src/net.h b/src/net.h index 369d4fd..7306d13 100644 --- a/src/net.h +++ b/src/net.h @@ -29,8 +29,8 @@ extern int nBestHeight; -inline unsigned int ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } -inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } +inline uint64_t ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } +inline uint64_t SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } void AddOneShot(std::string strDest); bool RecvLine(SOCKET hSocket, std::string& strLine); @@ -39,6 +39,7 @@ void AddressCurrentlyConnected(const CService& addr); CNode* FindNode(const CNetAddr& ip); CNode* FindNode(const CService& ip); CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, int64_t nTimeout=0); +bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false); void MapPort(); unsigned short GetListenPort(); bool BindListenPort(const CService &bindAddr, std::string& strError=REF(std::string())); @@ -125,6 +126,8 @@ extern CAddrMan addrman; extern std::vector vNodes; extern CCriticalSection cs_vNodes; +extern std::vector vAddedNodes; +extern CCriticalSection cs_vAddedNodes; extern std::map mapRelay; extern std::deque > vRelayExpiration; extern CCriticalSection cs_mapRelay; @@ -141,12 +144,12 @@ public: int64_t nLastRecv; int64_t nTimeConnected; std::string addrName; - int nVersion; + int32_t nVersion; std::string strSubVer; bool fInbound; int64_t nReleaseTime; - int nStartingHeight; - int nMisbehavior; + int32_t nStartingHeight; + int32_t nMisbehavior; uint64_t nSendBytes; uint64_t nRecvBytes; bool fSyncNode; @@ -173,12 +176,12 @@ public: int64_t nLastRecv; int64_t nLastSendEmpty; int64_t nTimeConnected; - int nHeaderStart; - unsigned int nMessageStart; + int32_t nHeaderStart; + uint32_t nMessageStart; CAddress addr; std::string addrName; CService addrLocal; - int nVersion; + int32_t nVersion; std::string strSubVer; bool fOneShot; bool fClient; @@ -203,7 +206,7 @@ public: uint256 hashContinue; CBlockIndex* pindexLastGetBlocksBegin; uint256 hashLastGetBlocksEnd; - int nStartingHeight; + int32_t nStartingHeight; bool fStartSync; // flood relay @@ -230,7 +233,7 @@ public: nLastSendEmpty = GetTime(); nTimeConnected = GetTime(); nHeaderStart = -1; - nMessageStart = -1; + nMessageStart = UINT_MAX; addr = addrIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; nVersion = 0; @@ -251,7 +254,7 @@ public: fGetAddr = false; nMisbehavior = 0; hashCheckpointKnown = 0; - setInventoryKnown.max_size(SendBufferSize() / 1000); + setInventoryKnown.max_size((size_t)SendBufferSize() / 1000); // Be shy and don't send version until we hear if (hSocket != INVALID_SOCKET && !fInbound) @@ -359,9 +362,9 @@ public: ENTER_CRITICAL_SECTION(cs_vSend); if (nHeaderStart != -1) AbortMessage(); - nHeaderStart = vSend.size(); + nHeaderStart = (int32_t)vSend.size(); vSend << CMessageHeader(pszCommand, 0); - nMessageStart = vSend.size(); + nMessageStart = (uint32_t)vSend.size(); if (fDebug) printf("sending: %s ", pszCommand); } @@ -372,7 +375,7 @@ public: return; vSend.resize(nHeaderStart); nHeaderStart = -1; - nMessageStart = -1; + nMessageStart = UINT_MAX; LEAVE_CRITICAL_SECTION(cs_vSend); if (fDebug) @@ -392,12 +395,12 @@ public: return; // Set the size - unsigned int nSize = vSend.size() - nMessageStart; + uint32_t nSize = (uint32_t) vSend.size() - nMessageStart; memcpy((char*)&vSend[nHeaderStart] + CMessageHeader::MESSAGE_SIZE_OFFSET, &nSize, sizeof(nSize)); // Set the checksum uint256 hash = Hash(vSend.begin() + nMessageStart, vSend.end()); - unsigned int nChecksum = 0; + uint32_t nChecksum = 0; memcpy(&nChecksum, &hash, sizeof(nChecksum)); assert(nMessageStart - nHeaderStart >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum)); memcpy((char*)&vSend[nHeaderStart] + CMessageHeader::CHECKSUM_OFFSET, &nChecksum, sizeof(nChecksum)); @@ -407,7 +410,7 @@ public: } nHeaderStart = -1; - nMessageStart = -1; + nMessageStart = UINT_MAX; LEAVE_CRITICAL_SECTION(cs_vSend); } @@ -415,7 +418,7 @@ public: { if (nHeaderStart < 0) return; - int nSize = vSend.size() - nMessageStart; + int nSize = (int) vSend.size() - nMessageStart; if (nSize > 0) EndMessage(); else