Merge pull request #1833 from jgarzik/mempool-query

Send 'mempool' P2P command at the start of each P2P session
This commit is contained in:
Jeff Garzik 2012-10-08 15:12:25 -07:00
commit 56caa38a67
2 changed files with 18 additions and 1 deletions

View file

@ -25,6 +25,7 @@ using namespace boost;
CWallet* pwalletMain; CWallet* pwalletMain;
CClientUIInterface uiInterface; CClientUIInterface uiInterface;
int64 nTimeNodeStart;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //
@ -470,8 +471,10 @@ bool AppInit2()
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str()); printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str());
printf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION)); printf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
nTimeNodeStart = GetTime();
if (!fLogTimestamps) if (!fLogTimestamps)
printf("Startup time: %s\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); printf("Startup time: %s\n", DateTimeStrFormat("%x %H:%M:%S", nTimeNodeStart).c_str());
printf("Default data directory %s\n", GetDefaultDataDir().string().c_str()); printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
printf("Used data directory %s\n", pszDataDir); printf("Used data directory %s\n", pszDataDir);
std::ostringstream strErrors; std::ostringstream strErrors;

View file

@ -2404,6 +2404,14 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv)
static bool NodeRecentlyStarted()
{
extern int64 nTimeNodeStart;
int64 timediff = GetTime() - nTimeNodeStart;
return (timediff < (2 * 60 * 60));
}
// The message start string is designed to be unlikely to occur in normal data. // The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce // The characters are rarely used upper ASCII, not valid as UTF-8, and produce
@ -2510,6 +2518,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
} }
} }
// Trigger download of remote node's memory pool
if (!IsInitialBlockDownload() && !pfrom->fInbound &&
!pfrom->fClient && NodeRecentlyStarted() &&
pfrom->nVersion >= MEMPOOL_GD_VERSION)
pfrom->PushMessage("mempool");
// Ask the first connected node for block updates // Ask the first connected node for block updates
static int nAskedForBlocks = 0; static int nAskedForBlocks = 0;
if (!pfrom->fClient && !pfrom->fOneShot && if (!pfrom->fClient && !pfrom->fOneShot &&