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.
This commit is contained in:
parent
da9beb288d
commit
9524c4d35c
1 changed files with 7 additions and 7 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -4248,6 +4248,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
|
|
||||||
mapAlreadyAskedFor.erase(inv);
|
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))
|
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
|
||||||
{
|
{
|
||||||
mempool.check(pcoinsTip);
|
mempool.check(pcoinsTip);
|
||||||
|
@ -4323,13 +4327,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
if (nEvicted > 0)
|
if (nEvicted > 0)
|
||||||
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
|
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
|
||||||
} else {
|
} else {
|
||||||
// AcceptToMemoryPool() returned false, possibly because the tx is
|
assert(recentRejects);
|
||||||
// already in the mempool; if the tx isn't in the mempool that
|
recentRejects->insert(tx.GetHash());
|
||||||
// means it was rejected and we shouldn't ask for it again.
|
|
||||||
if (!mempool.exists(tx.GetHash())) {
|
|
||||||
assert(recentRejects);
|
|
||||||
recentRejects->insert(tx.GetHash());
|
|
||||||
}
|
|
||||||
if (pfrom->fWhitelisted) {
|
if (pfrom->fWhitelisted) {
|
||||||
// Always relay transactions received from whitelisted peers, even
|
// Always relay transactions received from whitelisted peers, even
|
||||||
// if they were rejected from the mempool, allowing the node to
|
// if they were rejected from the mempool, allowing the node to
|
||||||
|
|
Loading…
Reference in a new issue