Add function to convert CValidationState to a human-readable message

It is necessary to be able to concisely log a validation state.
Convert CValidationState to a human-readable message for logging.
This commit is contained in:
Wladimir J. van der Laan 2015-08-06 09:53:24 +02:00
parent dc58258adf
commit 9003c7cdd8

View File

@ -778,6 +778,14 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
return nMinFee; return nMinFee;
} }
/** Convert CValidationState to a human-readable message for logging */
static std::string FormatStateMessage(const CValidationState &state)
{
return strprintf("%s%s (code %i)",
state.GetRejectReason(),
state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage(),
state.GetRejectCode());
}
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
bool* pfMissingInputs, bool fRejectAbsurdFee) bool* pfMissingInputs, bool fRejectAbsurdFee)