From 54470e767bab37f9b7089782b1be73d5883bb244 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Thu, 21 Feb 2019 13:46:25 -0500 Subject: Assert validation reasons are contextually correct --- src/consensus/validation.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/consensus/validation.h') diff --git a/src/consensus/validation.h b/src/consensus/validation.h index ed1b047614..3079f3b08c 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -66,6 +66,32 @@ enum class ValidationInvalidReason { TX_MEMPOOL_POLICY, //!< violated mempool's fee/size/descendant/RBF/etc limits }; +inline bool IsTransactionReason(ValidationInvalidReason r) +{ + return r == ValidationInvalidReason::NONE || + r == ValidationInvalidReason::CONSENSUS || + r == ValidationInvalidReason::RECENT_CONSENSUS_CHANGE || + r == ValidationInvalidReason::TX_NOT_STANDARD || + r == ValidationInvalidReason::TX_MISSING_INPUTS || + r == ValidationInvalidReason::TX_WITNESS_MUTATED || + r == ValidationInvalidReason::TX_CONFLICT || + r == ValidationInvalidReason::TX_MEMPOOL_POLICY; +} + +inline bool IsBlockReason(ValidationInvalidReason r) +{ + return r == ValidationInvalidReason::NONE || + r == ValidationInvalidReason::CONSENSUS || + r == ValidationInvalidReason::RECENT_CONSENSUS_CHANGE || + r == ValidationInvalidReason::CACHED_INVALID || + r == ValidationInvalidReason::BLOCK_INVALID_HEADER || + r == ValidationInvalidReason::BLOCK_MUTATED || + r == ValidationInvalidReason::BLOCK_MISSING_PREV || + r == ValidationInvalidReason::BLOCK_INVALID_PREV || + r == ValidationInvalidReason::BLOCK_TIME_FUTURE || + r == ValidationInvalidReason::BLOCK_CHECKPOINT; +} + /** Capture information about block/transaction validation */ class CValidationState { private: -- cgit v1.2.3