| 581 | } |
| 582 | |
| 583 | bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry) |
| 584 | { |
| 585 | AssertLockHeld(m_cs_fee_estimator); |
| 586 | if (!_removeTx(entry->GetTx().GetHash(), true)) { |
| 587 | // This transaction wasn't being tracked for fee estimation |
| 588 | return false; |
| 589 | } |
| 590 | |
| 591 | // How many blocks did it take for miners to include this transaction? |
| 592 | // blocksToConfirm is 1-based, so a transaction included in the earliest |
| 593 | // possible block has confirmation count of 1 |
| 594 | int blocksToConfirm = nBlockHeight - entry->GetHeight(); |
| 595 | if (blocksToConfirm <= 0) { |
| 596 | // This can't happen because we don't process transactions from a block with a height |
| 597 | // lower than our greatest seen height |
| 598 | LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error Transaction had negative blocksToConfirm\n"); |
| 599 | return false; |
| 600 | } |
| 601 | |
| 602 | // Feerates are stored and reported as BTC-per-kb: |
| 603 | CFeeRate feeRate(entry->GetFee(), entry->GetTxSize()); |
| 604 | |
| 605 | feeStats->Record(blocksToConfirm, (double)feeRate.GetFeePerK()); |
| 606 | shortStats->Record(blocksToConfirm, (double)feeRate.GetFeePerK()); |
| 607 | longStats->Record(blocksToConfirm, (double)feeRate.GetFeePerK()); |
| 608 | return true; |
| 609 | } |
| 610 | |
| 611 | void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight, |
| 612 | std::vector<const CTxMemPoolEntry*>& entries) |