aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorAlex Morcos <[email protected]>2016-11-11 13:29:13 -0500
committerAlex Morcos <[email protected]>2017-01-04 12:10:17 -0500
commitdc008c462f6df84dd444c9646f7ca64ee1c8c841 (patch)
treed9ad056188457ee015bba64c346b01cd2b358b4f /src/validation.cpp
parentPass pointers to existing CTxMemPoolEntries to fee estimation (diff)
downloaddiscoin-dc008c462f6df84dd444c9646f7ca64ee1c8c841.tar.xz
discoin-dc008c462f6df84dd444c9646f7ca64ee1c8c841.zip
Add IsCurrentForFeeEstimatation
Make a more conservative notion of whether the node is caught up to the rest of the network and only count transactions as fee estimation data points if the node is caught up.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index fb6a902bc..264fdd83d 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -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)
@@ -941,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.HasNoInputsOf(tx));
+ pool.addUnchecked(hash, entry, setAncestors, validForFeeEstimation);
// trim mempool and check if tx was trimmed
if (!fOverrideMempoolLimit) {