| 547 | } |
| 548 | |
| 549 | void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate) |
| 550 | { |
| 551 | LOCK(cs_feeEstimator); |
| 552 | unsigned int txHeight = entry.GetHeight(); |
| 553 | uint256 hash = entry.GetTx().GetHash(); |
| 554 | if (mapMemPoolTxs.count(hash)) { |
| 555 | LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error mempool tx %s already being tracked\n", |
| 556 | hash.ToString().c_str()); |
| 557 | return; |
| 558 | } |
| 559 | |
| 560 | if (txHeight != nBestSeenHeight) { |
| 561 | // Ignore side chains and re-orgs; assuming they are random they don't |
| 562 | // affect the estimate. We'll potentially double count transactions in 1-block reorgs. |
| 563 | // Ignore txs if BlockPolicyEstimator is not in sync with chainActive.Tip(). |
| 564 | // It will be synced next time a block is processed. |
| 565 | return; |
| 566 | } |
| 567 | |
| 568 | // Only want to be updating estimates when our blockchain is synced, |
| 569 | // otherwise we'll miscalculate how many blocks its taking to get included. |
| 570 | if (!validFeeEstimate) { |
| 571 | untrackedTxs++; |
| 572 | return; |
| 573 | } |
| 574 | trackedTxs++; |
| 575 | |
| 576 | // Feerates are stored and reported as BTC-per-kb: |
| 577 | CFeeRate feeRate(entry.GetFee(), entry.GetTxSize()); |
| 578 | |
| 579 | mapMemPoolTxs[hash].blockHeight = txHeight; |
| 580 | unsigned int bucketIndex = feeStats->NewTx(txHeight, (double)feeRate.GetFeePerK()); |
| 581 | mapMemPoolTxs[hash].bucketIndex = bucketIndex; |
| 582 | unsigned int bucketIndex2 = shortStats->NewTx(txHeight, (double)feeRate.GetFeePerK()); |
| 583 | assert(bucketIndex == bucketIndex2); |
| 584 | unsigned int bucketIndex3 = longStats->NewTx(txHeight, (double)feeRate.GetFeePerK()); |
| 585 | assert(bucketIndex == bucketIndex3); |
| 586 | } |
| 587 | |
| 588 | bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry) |
| 589 | { |
no test coverage detected