mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 03:33:32 +01:00
Merge #9138: Improve fee estimation
44b64b9Fix edge case with stale fee estimates (Alex Morcos)78ae62dAdd clarifying comments to fee estimation (Alex Morcos)5fe0f47Add extra logging to processBlock in fee estimation. (Alex Morcos)dc008c4Add IsCurrentForFeeEstimatation (Alex Morcos)ebafdcaPass pointers to existing CTxMemPoolEntries to fee estimation (Alex Morcos)d825838Always update fee estimates on new blocks. (Alex Morcos)6f06b26rename bool to validFeeEstimate (Alex Morcos)84f7ab0Remove member variable hadNoDependencies from CTxMemPoolEntry (Alex Morcos)60ac00dDon't track transactions at all during IBD. (Alex Morcos)4df4479Remove extraneous LogPrint from fee estimation (Alex Morcos)
This commit is contained in:
@@ -525,6 +525,18 @@ std::string FormatStateMessage(const CValidationState &state)
|
||||
state.GetRejectCode());
|
||||
}
|
||||
|
||||
static bool IsCurrentForFeeEstimation()
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
if (IsInitialBlockDownload())
|
||||
return false;
|
||||
if (chainActive.Tip()->GetBlockTime() < (GetTime() - MAX_FEE_ESTIMATION_TIP_AGE))
|
||||
return false;
|
||||
if (chainActive.Height() < pindexBestHeader->nHeight - 1)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const CTransactionRef& ptx, bool fLimitFree,
|
||||
bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit, const CAmount& nAbsurdFee,
|
||||
std::vector<uint256>& vHashTxnToUncache)
|
||||
@@ -692,7 +704,8 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||
}
|
||||
}
|
||||
|
||||
CTxMemPoolEntry entry(ptx, nFees, nAcceptTime, dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbase, nSigOpsCost, lp);
|
||||
CTxMemPoolEntry entry(ptx, nFees, nAcceptTime, dPriority, chainActive.Height(),
|
||||
inChainInputValue, fSpendsCoinbase, nSigOpsCost, lp);
|
||||
unsigned int nSize = entry.GetTxSize();
|
||||
|
||||
// Check that the transaction doesn't have an excessive number of
|
||||
@@ -940,8 +953,13 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||
}
|
||||
pool.RemoveStaged(allConflicting, false);
|
||||
|
||||
// This transaction should only count for fee estimation if
|
||||
// the node is not behind and it is not dependent on any other
|
||||
// transactions in the mempool
|
||||
bool validForFeeEstimation = IsCurrentForFeeEstimation() && pool.HasNoInputsOf(tx);
|
||||
|
||||
// Store transaction in memory
|
||||
pool.addUnchecked(hash, entry, setAncestors, !IsInitialBlockDownload());
|
||||
pool.addUnchecked(hash, entry, setAncestors, validForFeeEstimation);
|
||||
|
||||
// trim mempool and check if tx was trimmed
|
||||
if (!fOverrideMempoolLimit) {
|
||||
@@ -2206,7 +2224,7 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
|
||||
int64_t nTime5 = GetTimeMicros(); nTimeChainState += nTime5 - nTime4;
|
||||
LogPrint("bench", " - Writing chainstate: %.2fms [%.2fs]\n", (nTime5 - nTime4) * 0.001, nTimeChainState * 0.000001);
|
||||
// Remove conflicting transactions from the mempool.;
|
||||
mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight, !IsInitialBlockDownload());
|
||||
mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
|
||||
// Update chainActive & related variables.
|
||||
UpdateTip(pindexNew, chainparams);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user