aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-09-24 13:53:44 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-09-24 13:53:44 -0400
commit22f9b069035c9ba0416a62714db167eea5ba762f (patch)
treed66bd49469e7094db5ac7603d2379748f282116a /src/main.cpp
parent6cbae37667f504d9ecd6173e1eff817d2b7aaf0c (diff)
Send 'mempool' P2P command at the start of each P2P session
to query remote node mempool contents.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fbaf05dfc7..d1f84a12e0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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 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
static int nAskedForBlocks = 0;
if (!pfrom->fClient && !pfrom->fOneShot &&