mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Treat orphans as implicit inv for parents, discard when parents rejected.
An orphan whos parents were rejected is never going to connect, so there is little utility in keeping it. Orphans also helpfully tell us what we're missing, so go ahead and treat it as INVed.
This commit is contained in:
parent
11cc143895
commit
8c99d1b525
16
src/main.cpp
16
src/main.cpp
@ -5156,6 +5156,19 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
else if (fMissingInputs)
|
||||
{
|
||||
bool fRejectedParents = false; // It may be the case that the orphans parents have all been rejected
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
||||
if (recentRejects->contains(txin.prevout.hash)) {
|
||||
fRejectedParents = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fRejectedParents) {
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
||||
CInv inv(MSG_TX, txin.prevout.hash);
|
||||
pfrom->AddInventoryKnown(inv);
|
||||
if (!AlreadyHave(inv)) pfrom->AskFor(inv);
|
||||
}
|
||||
AddOrphanTx(tx, pfrom->GetId());
|
||||
|
||||
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
|
||||
@ -5163,6 +5176,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx);
|
||||
if (nEvicted > 0)
|
||||
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
|
||||
} else {
|
||||
LogPrint("mempool", "not keeping orphan with rejected parents %s\n",tx.GetHash().ToString());
|
||||
}
|
||||
} else {
|
||||
assert(recentRejects);
|
||||
recentRejects->insert(tx.GetHash());
|
||||
|
Loading…
Reference in New Issue
Block a user