Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | |||||
/** Convert CValidationState to a human-readable message for logging */ | /** Convert CValidationState to a human-readable message for logging */ | ||||
std::string FormatStateMessage(const CValidationState &state) { | std::string FormatStateMessage(const CValidationState &state) { | ||||
return strprintf( | return strprintf( | ||||
"%s%s (code %i)", state.GetRejectReason(), | "%s%s (code %i)", state.GetRejectReason(), | ||||
state.GetDebugMessage().empty() ? "" : ", " + state.GetDebugMessage(), | state.GetDebugMessage().empty() ? "" : ", " + state.GetDebugMessage(), | ||||
state.GetRejectCode()); | 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; | |||||
} | |||||
static bool IsMagneticAnomalyEnabledForCurrentBlock(const Config &config) { | static bool IsMagneticAnomalyEnabledForCurrentBlock(const Config &config) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
return IsMagneticAnomalyEnabled(config, chainActive.Tip()); | return IsMagneticAnomalyEnabled(config, chainActive.Tip()); | ||||
} | } | ||||
static bool IsGreatWallEnabledForCurrentBlock(const Config &config) { | static bool IsGreatWallEnabledForCurrentBlock(const Config &config) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
return IsGreatWallEnabled(config, chainActive.Tip()); | return IsGreatWallEnabled(config, chainActive.Tip()); | ||||
▲ Show 20 Lines • Show All 391 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
__func__, txid.ToString(), FormatStateMessage(state)); | __func__, txid.ToString(), FormatStateMessage(state)); | ||||
} | } | ||||
LogPrintf("Warning: -promiscuousmempool flags set to not include " | LogPrintf("Warning: -promiscuousmempool flags set to not include " | ||||
"currently enforced soft forks, this may break mining or " | "currently enforced soft forks, this may break mining or " | ||||
"otherwise cause instability!\n"); | "otherwise cause instability!\n"); | ||||
} | } | ||||
// 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. | // Store transaction in memory. | ||||
pool.addUnchecked(txid, entry, setAncestors, validForFeeEstimation); | pool.addUnchecked(txid, entry, setAncestors); | ||||
// Trim mempool and check if tx was trimmed. | // Trim mempool and check if tx was trimmed. | ||||
if (!fOverrideMempoolLimit) { | if (!fOverrideMempoolLimit) { | ||||
pool.LimitSize( | pool.LimitSize( | ||||
gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, | gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, | ||||
gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * | gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * | ||||
60); | 60); | ||||
if (!pool.exists(txid)) { | if (!pool.exists(txid)) { | ||||
▲ Show 20 Lines • Show All 4,855 Lines • Show Last 20 Lines |