@ -5156,13 +5156,29 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
}
else if ( fMissingInputs )
else if ( fMissingInputs )
{
{
AddOrphanTx ( tx , pfrom - > GetId ( ) ) ;
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
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
unsigned int nMaxOrphanTx = ( unsigned int ) std : : max ( ( int64_t ) 0 , GetArg ( " -maxorphantx " , DEFAULT_MAX_ORPHAN_TRANSACTIONS ) ) ;
unsigned int nMaxOrphanTx = ( unsigned int ) std : : max ( ( int64_t ) 0 , GetArg ( " -maxorphantx " , DEFAULT_MAX_ORPHAN_TRANSACTIONS ) ) ;
unsigned int nEvicted = LimitOrphanTxSize ( nMaxOrphanTx ) ;
unsigned int nEvicted = LimitOrphanTxSize ( nMaxOrphanTx ) ;
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 {
LogPrint ( " mempool " , " not keeping orphan with rejected parents %s \n " , tx . GetHash ( ) . ToString ( ) ) ;
}
} else {
} else {
assert ( recentRejects ) ;
assert ( recentRejects ) ;
recentRejects - > insert ( tx . GetHash ( ) ) ;
recentRejects - > insert ( tx . GetHash ( ) ) ;