aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Hearn <hearn@google.com>2013-01-19 18:48:26 +0100
committerMike Hearn <hearn@google.com>2013-01-19 18:48:26 +0100
commit903d146030e741441c288873ef3c682fb5019101 (patch)
treef41e6b95b477bb618e8bc35599cbae4e5cdfcca3
parentbd85cf3df786898fa0e1f584eca840d3ec05edb2 (diff)
Add a notfound message to getdata that is sent if any transactions that aren't in the relayable set are requested.
-rw-r--r--src/main.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a6394e0bff..d086473028 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3244,6 +3244,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (fDebugNet || (vInv.size() != 1))
printf("received getdata (%"PRIszu" invsz)\n", vInv.size());
+ vector<CInv> vNotFound;
BOOST_FOREACH(const CInv& inv, vInv)
{
if (fShutdown)
@@ -3316,12 +3317,27 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
ss.reserve(1000);
ss << tx;
pfrom->PushMessage("tx", ss);
+ pushed = true;
}
}
+ if (!pushed) {
+ vNotFound.push_back(inv);
+ }
}
- // Track requests for our stuff
+ // Track requests for our stuff.
Inventory(inv.hash);
+
+ if (!vNotFound.empty()) {
+ // Let the peer know that we didn't find what it asked for, so it doesn't
+ // have to wait around forever. Currently only SPV clients actually care
+ // about this message: it's needed when they are recursively walking the
+ // dependencies of relevant unconfirmed transactions. SPV clients want to
+ // do that because they want to know about (and store and rebroadcast and
+ // risk analyze) the dependencies of transactions relevant to them, without
+ // having to download the entire memory pool.
+ pfrom->PushMessage("notfound", vNotFound);
+ }
}
}