aboutsummaryrefslogtreecommitdiff
path: root/net.h
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-13 01:23:08 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-13 01:23:08 +0000
commit70e79525c97c33a5fca8674d47d86cc2b7ae197a (patch)
tree7427ce9b17468ed4a9dec82b380c2dd40a5332ca /net.h
parent956468c29adcbff83ab7c2e52d91f8e87b704853 (diff)
downloadbitcoin-70e79525c97c33a5fca8674d47d86cc2b7ae197a.tar.xz
monitor ThreadSocketHandler and terminate and restart if hung, convert _beginthread to CreateThread wrapper, disconnect inactive connections, ping, break up long messages to speed up initial download, better priorities for initiating connections, track how many nodes have requested our blocks and transactions, status #/offline and warning message on unsent blocks, minimize on close as separate option -- linux-test5
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@38 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'net.h')
-rw-r--r--net.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/net.h b/net.h
index 7b83d462fe..6300d3efcf 100644
--- a/net.h
+++ b/net.h
@@ -29,7 +29,7 @@ CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
bool AnySubscribed(unsigned int nChannel);
bool BindListenPort(string& strError=REF(string()));
-bool StartNode(string& strError=REF(string()));
+void StartNode(void* parg);
bool StopNode();
@@ -39,7 +39,6 @@ bool StopNode();
-
//
// Message header
// (4) message start
@@ -139,7 +138,7 @@ public:
unsigned int nTime;
// memory only
- unsigned int nLastFailed;
+ unsigned int nLastTry;
CAddress()
{
@@ -183,7 +182,7 @@ public:
ip = INADDR_NONE;
port = DEFAULT_PORT;
nTime = GetAdjustedTime();
- nLastFailed = 0;
+ nLastTry = 0;
}
bool SetAddress(const char* pszIn)
@@ -458,6 +457,7 @@ extern uint64 nLocalHostNonce;
extern bool fShutdown;
extern array<int, 10> vnThreadsRunning;
extern SOCKET hListenSocket;
+extern int64 nThreadSocketHandlerHeartbeat;
extern vector<CNode*> vNodes;
extern CCriticalSection cs_vNodes;
@@ -486,6 +486,10 @@ public:
CDataStream vRecv;
CCriticalSection cs_vSend;
CCriticalSection cs_vRecv;
+ int64 nLastSend;
+ int64 nLastRecv;
+ int64 nLastSendEmpty;
+ int64 nTimeConnected;
unsigned int nPushPos;
CAddress addr;
int nVersion;
@@ -523,6 +527,10 @@ public:
hSocket = hSocketIn;
vSend.SetType(SER_NETWORK);
vRecv.SetType(SER_NETWORK);
+ nLastSend = 0;
+ nLastRecv = 0;
+ nLastSendEmpty = GetTime();
+ nTimeConnected = GetTime();
nPushPos = -1;
addr = addrIn;
nVersion = 0;
@@ -542,7 +550,7 @@ public:
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);
+ PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, "linux-test5");
}
~CNode()
@@ -557,11 +565,6 @@ private:
public:
- bool ReadyToDisconnect()
- {
- return fDisconnect || GetRefCount() <= 0;
- }
-
int GetRefCount()
{
return max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);
@@ -635,6 +638,8 @@ public:
AbortMessage();
nPushPos = vSend.size();
vSend << CMessageHeader(pszCommand, 0);
+ if (fDebug)
+ printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("sending: %s ", pszCommand);
}