|
|
@ -19,7 +19,6 @@ |
|
|
|
#include "protocol.h" |
|
|
|
#include "protocol.h" |
|
|
|
#include "addrman.h" |
|
|
|
#include "addrman.h" |
|
|
|
|
|
|
|
|
|
|
|
class CRequestTracker; |
|
|
|
|
|
|
|
class CNode; |
|
|
|
class CNode; |
|
|
|
class CBlockIndex; |
|
|
|
class CBlockIndex; |
|
|
|
extern int nBestHeight; |
|
|
|
extern int nBestHeight; |
|
|
@ -74,25 +73,6 @@ enum |
|
|
|
MSG_BLOCK, |
|
|
|
MSG_BLOCK, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class CRequestTracker |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
void (*fn)(void*, CDataStream&); |
|
|
|
|
|
|
|
void* param1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
explicit CRequestTracker(void (*fnIn)(void*, CDataStream&)=NULL, void* param1In=NULL) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fn = fnIn; |
|
|
|
|
|
|
|
param1 = param1In; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool IsNull() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return fn == NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Thread types */ |
|
|
|
/** Thread types */ |
|
|
|
enum threadId |
|
|
|
enum threadId |
|
|
|
{ |
|
|
|
{ |
|
|
@ -189,8 +169,6 @@ protected: |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
int64 nReleaseTime; |
|
|
|
int64 nReleaseTime; |
|
|
|
std::map<uint256, CRequestTracker> mapRequests; |
|
|
|
|
|
|
|
CCriticalSection cs_mapRequests; |
|
|
|
|
|
|
|
uint256 hashContinue; |
|
|
|
uint256 hashContinue; |
|
|
|
CBlockIndex* pindexLastGetBlocksBegin; |
|
|
|
CBlockIndex* pindexLastGetBlocksBegin; |
|
|
|
uint256 hashLastGetBlocksEnd; |
|
|
|
uint256 hashLastGetBlocksEnd; |
|
|
@ -564,53 +542,6 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PushRequest(const char* pszCommand, |
|
|
|
|
|
|
|
void (*fn)(void*, CDataStream&), void* param1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uint256 hashReply; |
|
|
|
|
|
|
|
RAND_bytes((unsigned char*)&hashReply, sizeof(hashReply)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_mapRequests); |
|
|
|
|
|
|
|
mapRequests[hashReply] = CRequestTracker(fn, param1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PushMessage(pszCommand, hashReply); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T1> |
|
|
|
|
|
|
|
void PushRequest(const char* pszCommand, const T1& a1, |
|
|
|
|
|
|
|
void (*fn)(void*, CDataStream&), void* param1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uint256 hashReply; |
|
|
|
|
|
|
|
RAND_bytes((unsigned char*)&hashReply, sizeof(hashReply)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_mapRequests); |
|
|
|
|
|
|
|
mapRequests[hashReply] = CRequestTracker(fn, param1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PushMessage(pszCommand, hashReply, a1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T1, typename T2> |
|
|
|
|
|
|
|
void PushRequest(const char* pszCommand, const T1& a1, const T2& a2, |
|
|
|
|
|
|
|
void (*fn)(void*, CDataStream&), void* param1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uint256 hashReply; |
|
|
|
|
|
|
|
RAND_bytes((unsigned char*)&hashReply, sizeof(hashReply)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_mapRequests); |
|
|
|
|
|
|
|
mapRequests[hashReply] = CRequestTracker(fn, param1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PushMessage(pszCommand, hashReply, a1, a2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd); |
|
|
|
void PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd); |
|
|
|
bool IsSubscribed(unsigned int nChannel); |
|
|
|
bool IsSubscribed(unsigned int nChannel); |
|
|
|
void Subscribe(unsigned int nChannel, unsigned int nHops=0); |
|
|
|
void Subscribe(unsigned int nChannel, unsigned int nHops=0); |
|
|
|