Subject: [bitcoin-dev] TXMempool and dirty entries

From: "DJ Bitcoin" <[email-masked]>
Date: Mon, 8 May 2017 11:38:16 +0200

Hi Guys,

I have a question about the use of txmempool. find attached the code in txmempool.h

======================================================

/* Adding transactions from a disconnected block can be very time consuming,
* because we don't have a way to limit the number of in-mempool descendants.
* To bound CPU processing, we limit the amount of work we're willing to do
* to properly update the descendant information for a tx being added from
* a disconnected block.  If we would exceed the limit, then we instead mark
* the entry as "dirty", and set the feerate for sorting purposes to be equal
* the feerate of the transaction without any descendants. */

class CTxMemPoolEntry

{

private:

// ...

// Information about descendants of this transaction that are in the
// mempool; if we remove this transaction we must remove all of these

// descendants as well. if nCountWithDescendants is 0, treat this entry as
// dirty, and nSizeWithDescendants and nModFeesWithDescendants will not be

// correct.

int64_t nCountWithDescendants; //!< number of descendant transactions
// ...

======================================================

Now, the only place where nCountWithDescendants is modified is the following (txmempool.cpp):

======================================================
void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
{
nSizeWithDescendants += modifySize;
assert(int64_t(nSizeWithDescendants) > 0);
nModFeesWithDescendants += modifyFee;
nCountWithDescendants += modifyCount;
assert(int64_t(nCountWithDescendants) > 0);
}

======================================================

Therefore, nCountWithDescendants is never zero.

Am i missing something? Where is this concept of "dirty" defined?

Thanks a lot,

DJ