X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fnet.h;h=bb0620641b3d26bd9edca743cb0bf0abdc4f1494;hb=d008ea3376606276a86ed3c972654363eb23f47d;hp=8a8916a1d2ff9a5121d53a7b5ca58821c529e6fa;hpb=9f3020f117dec258f93def05cbdb27d86917a015;p=novacoin.git diff --git a/src/net.h b/src/net.h index 8a8916a..bb06206 100644 --- a/src/net.h +++ b/src/net.h @@ -6,8 +6,10 @@ #define BITCOIN_NET_H #include +#ifndef Q_MOC_RUN #include #include +#endif #include #ifndef WIN32 @@ -18,6 +20,7 @@ #include "netbase.h" #include "protocol.h" #include "addrman.h" +#include "hash.h" class CRequestTracker; class CNode; @@ -106,6 +109,7 @@ enum threadId THREAD_DUMPADDRESS, THREAD_RPCHANDLER, THREAD_MINTER, + THREAD_SCRIPTCHECK, THREAD_MAX }; @@ -143,6 +147,9 @@ public: int64 nReleaseTime; int nStartingHeight; int nMisbehavior; + uint64 nSendBytes; + uint64 nRecvBytes; + bool fSyncNode; }; @@ -158,6 +165,8 @@ public: SOCKET hSocket; CDataStream vSend; CDataStream vRecv; + uint64 nSendBytes; + uint64 nRecvBytes; CCriticalSection cs_vSend; CCriticalSection cs_vRecv; int64 nLastSend; @@ -195,6 +204,7 @@ public: CBlockIndex* pindexLastGetBlocksBegin; uint256 hashLastGetBlocksEnd; int nStartingHeight; + bool fStartSync; // flood relay std::vector vAddrToSend; @@ -215,6 +225,8 @@ public: hSocket = hSocketIn; nLastSend = 0; nLastRecv = 0; + nSendBytes = 0; + nRecvBytes = 0; nLastSendEmpty = GetTime(); nTimeConnected = GetTime(); nHeaderStart = -1; @@ -235,6 +247,7 @@ public: pindexLastGetBlocksBegin = 0; hashLastGetBlocksEnd = 0; nStartingHeight = -1; + fStartSync = false; fGetAddr = false; nMisbehavior = 0; hashCheckpointKnown = 0; @@ -254,7 +267,13 @@ public: } } + private: + // Network usage totals + static CCriticalSection cs_totalBytesRecv; + static CCriticalSection cs_totalBytesSent; + static uint64_t nTotalBytesRecv; + static uint64_t nTotalBytesSent; CNode(const CNode&); void operator=(const CNode&); public: @@ -319,7 +338,7 @@ public: // the key is the earliest time the request can be sent int64& nRequestTime = mapAlreadyAskedFor[inv]; if (fDebugNet) - printf("askfor %s %"PRI64d" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str()); + printf("askfor %s %" PRI64d " (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str()); // Make sure not to reuse time indexes to keep things in the same order int64 nNow = (GetTime() - 1) * 1000000; @@ -639,6 +658,12 @@ public: static bool IsBanned(CNetAddr ip); bool Misbehaving(int howmuch); // 1 == a little, 100 == a lot void copyStats(CNodeStats &stats); + // Network stats + static void RecordBytesRecv(uint64_t bytes); + static void RecordBytesSent(uint64_t bytes); + + static uint64_t GetTotalBytesRecv(); + static uint64_t GetTotalBytesSent(); }; inline void RelayInventory(const CInv& inv)