aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2019-04-28 12:17:56 -0500
committerJohn Newbery <john@johnnewbery.com>2019-10-29 15:46:45 -0400
commit067981e49246822421a7bcc720491427e1dba8a3 (patch)
treeb8242a101ba799aa11151ba3b4ca86d842a81bf3 /src
parenta27a2957ed9afbe5a96caa5f0f4cbec730d27460 (diff)
[validation] Tidy Up ValidationResult class
Minor style fixups and comment updates. This is purely a style change. There is no change in behavior.
Diffstat (limited to 'src')
-rw-r--r--src/consensus/validation.h63
1 files changed, 29 insertions, 34 deletions
diff --git a/src/consensus/validation.h b/src/consensus/validation.h
index c285817c0d..34bdf36c5f 100644
--- a/src/consensus/validation.h
+++ b/src/consensus/validation.h
@@ -85,42 +85,34 @@ private:
MODE_VALID, //!< everything ok
MODE_INVALID, //!< network rule violation (DoS value may be set)
MODE_ERROR, //!< run-time error
- } mode;
- std::string strRejectReason;
- std::string strDebugMessage;
+ } m_mode;
+ std::string m_reject_reason;
+ std::string m_debug_message;
protected:
- bool Invalid(bool ret = false,
- const std::string &strRejectReasonIn="",
- const std::string &strDebugMessageIn="") {
- strRejectReason = strRejectReasonIn;
- strDebugMessage = strDebugMessageIn;
- if (mode == MODE_ERROR)
- return ret;
- mode = MODE_INVALID;
- return ret;
+ void Invalid(const std::string &reject_reason="",
+ const std::string &debug_message="")
+ {
+ m_reject_reason = reject_reason;
+ m_debug_message = debug_message;
+ if (m_mode != MODE_ERROR) m_mode = MODE_INVALID;
}
public:
// ValidationState is abstract. Have a pure virtual destructor.
virtual ~ValidationState() = 0;
- ValidationState() : mode(MODE_VALID) {}
- bool Error(const std::string& strRejectReasonIn) {
- if (mode == MODE_VALID)
- strRejectReason = strRejectReasonIn;
- mode = MODE_ERROR;
+ ValidationState() : m_mode(MODE_VALID) {}
+ bool Error(const std::string& reject_reason)
+ {
+ if (m_mode == MODE_VALID)
+ m_reject_reason = reject_reason;
+ m_mode = MODE_ERROR;
return false;
}
- bool IsValid() const {
- return mode == MODE_VALID;
- }
- bool IsInvalid() const {
- return mode == MODE_INVALID;
- }
- bool IsError() const {
- return mode == MODE_ERROR;
- }
- std::string GetRejectReason() const { return strRejectReason; }
- std::string GetDebugMessage() const { return strDebugMessage; }
+ bool IsValid() const { return m_mode == MODE_VALID; }
+ bool IsInvalid() const { return m_mode == MODE_INVALID; }
+ bool IsError() const { return m_mode == MODE_ERROR; }
+ std::string GetRejectReason() const { return m_reject_reason; }
+ std::string GetDebugMessage() const { return m_debug_message; }
};
inline ValidationState::~ValidationState() {};
@@ -130,10 +122,12 @@ private:
TxValidationResult m_result;
public:
bool Invalid(TxValidationResult result, bool ret = false,
- const std::string &_strRejectReason="",
- const std::string &_strDebugMessage="") {
+ const std::string &reject_reason="",
+ const std::string &debug_message="")
+ {
m_result = result;
- return ValidationState::Invalid(ret, _strRejectReason, _strDebugMessage);
+ ValidationState::Invalid(reject_reason, debug_message);
+ return ret;
}
TxValidationResult GetResult() const { return m_result; }
};
@@ -143,10 +137,11 @@ private:
BlockValidationResult m_result;
public:
bool Invalid(BlockValidationResult result, bool ret = false,
- const std::string &_strRejectReason="",
- const std::string &_strDebugMessage="") {
+ const std::string &reject_reason="",
+ const std::string &debug_message="") {
m_result = result;
- return ValidationState::Invalid(ret, _strRejectReason, _strDebugMessage);
+ ValidationState::Invalid(reject_reason, debug_message);
+ return ret;
}
BlockValidationResult GetResult() const { return m_result; }
};