why using `blockIndex` in bitcoin's code `unconfTxs` I am reading the code of rpc's estimateSmartFee method , and I can't understand why using blockIndex in unconfTxs ? 

estimateSmartFee loop unconfTxs to get feeRate(code: https://github.com/bitcoin/bitcoin/blob/0.18/src/policy/fees.cpp#L291)

But the value unconfTxs[blockIndex][bucketindex] will be reseted in TxConfirmStats::ClearCurrent or reduced in TxConfirmStats::removeTx.
Why not just define like this unconfTxs[bucketindex]?

source file fees.cpp



unsigned int TxConfirmStats::NewTx(unsigned int nBlockHeight, double val)
{
    unsigned int bucketindex = bucketMap.lower_bound(val)-&gt;second;
    unsigned int blockIndex = nBlockHeight % unconfTxs.size();
    unconfTxs[blockIndex][bucketindex]++;
    return bucketindex;
}


the unconfTxs



    // Mempool counts of outstanding transactions
    // For each bucket X, track the number of transactions in the mempool
    // that are unconfirmed for each possible confirmation value Y
    std::vector&lt;std::vector&lt;int&gt; &gt; unconfTxs;  //unconfTxs[Y][X]
That whole vector is to keep track of how many blocks have passed since a transaction entered the mempool and what feerate it is. So it allows the estimator to look up how many transactions have been in the mempool for Y blocks at a feerate of X. This allows it to see what feerate is probably needed in order for a transaction to be confirmed in Y blocks.

If you just had the number of transactions at each feerate, that only tells you the feerate distribution of unconfirmed transactions. This is not helpful for estimating how many blocks will pass before a transaction becomes included in a block.