| 404 | } |
| 405 | |
| 406 | bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry) |
| 407 | { |
| 408 | if (!entry->WasClearAtEntry()) { |
| 409 | // This transaction depended on other transactions in the mempool to |
| 410 | // be included in a block before it was able to be included, so |
| 411 | // we shouldn't include it in our calculations |
| 412 | return false; |
| 413 | } |
| 414 | |
| 415 | // if (!removeTx(entry->GetTx().GetHash())) { |
| 416 | // // This transaction wasn't being tracked for fee estimation |
| 417 | // return false; |
| 418 | // } |
| 419 | |
| 420 | // How many blocks did it take for miners to include this transaction? |
| 421 | // blocksToConfirm is 1-based, so a transaction included in the earliest |
| 422 | // possible block has confirmation count of 1 |
| 423 | int blocksToConfirm = nBlockHeight - entry->GetHeight(); |
| 424 | if (blocksToConfirm <= 0) { |
| 425 | // This can't happen because we don't process transactions from a block with a height |
| 426 | // lower than our greatest seen height |
| 427 | LogPrint("estimatefee", "Blockpolicy error Transaction had negative blocksToConfirm\n"); |
| 428 | return false; |
| 429 | } |
| 430 | |
| 431 | // Feerates are stored and reported as BTC-per-kb: |
| 432 | CFeeRate feeRate(entry->GetFee(), entry->GetTxSize()); |
| 433 | |
| 434 | // Want the priority of the tx at confirmation. The priority when it |
| 435 | // entered the mempool could easily be very small and change quickly |
| 436 | double curPri = entry->GetPriority(nBlockHeight); |
| 437 | |
| 438 | // Record this as a priority estimate |
| 439 | if (entry->GetFee() == 0 || isPriDataPoint(feeRate, curPri)) { |
| 440 | priStats.Record(blocksToConfirm, curPri); |
| 441 | } |
| 442 | // Record this as a fee estimate |
| 443 | else if (isFeeDataPoint(feeRate, curPri)) { |
| 444 | feeStats.Record(blocksToConfirm, (double)feeRate.GetFeePerK()); |
| 445 | } |
| 446 | |
| 447 | return true; |
| 448 | } |
| 449 | |
| 450 | void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight, |
| 451 | std::vector<const CTxMemPoolEntry*>& entries, bool fCurrentEstimate) |
nothing calls this directly
no test coverage detected