aboutsummaryrefslogtreecommitdiff
path: root/src/consensus/validation.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/consensus/validation.h')
-rw-r--r--src/consensus/validation.h36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/consensus/validation.h b/src/consensus/validation.h
index a79e7b9d12..8de7a8f2d8 100644
--- a/src/consensus/validation.h
+++ b/src/consensus/validation.h
@@ -30,12 +30,16 @@ enum class TxValidationResult {
TX_MISSING_INPUTS, //!< transaction was missing some of its inputs
TX_PREMATURE_SPEND, //!< transaction spends a coinbase too early, or violates locktime/sequence locks
/**
- * Transaction might be missing a witness, have a witness prior to SegWit
+ * Transaction might have a witness prior to SegWit
* activation, or witness may have been malleated (which includes
* non-standard witnesses).
*/
TX_WITNESS_MUTATED,
/**
+ * Transaction is missing a witness.
+ */
+ TX_WITNESS_STRIPPED,
+ /**
* Tx already in mempool or conflicts with a tx in the chain
* (if it conflicts with another tx in mempool, we use MEMPOOL_POLICY as it failed to reach the RBF threshold)
* Currently this is only used if the transaction already exists in the mempool or on chain.
@@ -75,37 +79,39 @@ enum class BlockValidationResult {
* by TxValidationState and BlockValidationState for validation information on transactions
* and blocks respectively. */
template <typename Result>
-class ValidationState {
+class ValidationState
+{
private:
- enum mode_state {
- MODE_VALID, //!< everything ok
- MODE_INVALID, //!< network rule violation (DoS value may be set)
- MODE_ERROR, //!< run-time error
- } m_mode{MODE_VALID};
+ enum class ModeState {
+ M_VALID, //!< everything ok
+ M_INVALID, //!< network rule violation (DoS value may be set)
+ M_ERROR, //!< run-time error
+ } m_mode{ModeState::M_VALID};
Result m_result{};
std::string m_reject_reason;
std::string m_debug_message;
+
public:
bool Invalid(Result result,
- const std::string &reject_reason="",
- const std::string &debug_message="")
+ const std::string& reject_reason = "",
+ const std::string& debug_message = "")
{
m_result = result;
m_reject_reason = reject_reason;
m_debug_message = debug_message;
- if (m_mode != MODE_ERROR) m_mode = MODE_INVALID;
+ if (m_mode != ModeState::M_ERROR) m_mode = ModeState::M_INVALID;
return false;
}
bool Error(const std::string& reject_reason)
{
- if (m_mode == MODE_VALID)
+ if (m_mode == ModeState::M_VALID)
m_reject_reason = reject_reason;
- m_mode = MODE_ERROR;
+ m_mode = ModeState::M_ERROR;
return false;
}
- bool IsValid() const { return m_mode == MODE_VALID; }
- bool IsInvalid() const { return m_mode == MODE_INVALID; }
- bool IsError() const { return m_mode == MODE_ERROR; }
+ bool IsValid() const { return m_mode == ModeState::M_VALID; }
+ bool IsInvalid() const { return m_mode == ModeState::M_INVALID; }
+ bool IsError() const { return m_mode == ModeState::M_ERROR; }
Result GetResult() const { return m_result; }
std::string GetRejectReason() const { return m_reject_reason; }
std::string GetDebugMessage() const { return m_debug_message; }