aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorTom Harding <[email protected]>2015-08-24 14:02:24 -0700
committerTom Harding <[email protected]>2015-09-03 10:16:59 -0700
commit9524c4d35cb6ec4bd7becf1d938d21c536669d1f (patch)
tree43a091af6800d6e88828f0abb04c35cb34046192 /src/main.cpp
parentMerge pull request #6576 (diff)
downloaddiscoin-9524c4d35cb6ec4bd7becf1d938d21c536669d1f.tar.xz
discoin-9524c4d35cb6ec4bd7becf1d938d21c536669d1f.zip
In (strCommand == "tx"), return if AlreadyHave()
The main effect is to exit processing for recently-rejected hashes, in case they are pushed to us without prior advertisement. This behavior was seen in the wild. An additional effect is to do early checks for mempool or mapOrphan existence. No logging or nDoS tracking is needed for failures of these checks.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 33b57a528..6d07f83ce 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4248,6 +4248,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
mapAlreadyAskedFor.erase(inv);
+ // Check for recently rejected (and do other quick existence checks)
+ if (AlreadyHave(inv))
+ return true;
+
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
{
mempool.check(pcoinsTip);
@@ -4323,13 +4327,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (nEvicted > 0)
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
} else {
- // AcceptToMemoryPool() returned false, possibly because the tx is
- // already in the mempool; if the tx isn't in the mempool that
- // means it was rejected and we shouldn't ask for it again.
- if (!mempool.exists(tx.GetHash())) {
- assert(recentRejects);
- recentRejects->insert(tx.GetHash());
- }
+ assert(recentRejects);
+ recentRejects->insert(tx.GetHash());
+
if (pfrom->fWhitelisted) {
// Always relay transactions received from whitelisted peers, even
// if they were rejected from the mempool, allowing the node to