diff options
author | Jeffrey Czyz <jkczyz@gmail.com> | 2020-01-03 11:38:44 -0800 |
---|---|---|
committer | Jeffrey Czyz <jkczyz@gmail.com> | 2020-01-03 11:38:44 -0800 |
commit | 6edebacb2191373e76d79a4972d6192300976096 (patch) | |
tree | e2c49ba8ead3a5689ac266aa7849ecf5f5e03e13 /src/util/validation.cpp | |
parent | 72f3227c83810936e7a334304e5fd7c6dab8e91b (diff) |
Refactor FormatStateMessage for clarity
All cases of CValidationState were condensed into one strprintf call.
This is no longer suitable as more cases are added (e.g., IsValid).
Diffstat (limited to 'src/util/validation.cpp')
-rw-r--r-- | src/util/validation.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/util/validation.cpp b/src/util/validation.cpp index 603db51d45..ed9c108bb0 100644 --- a/src/util/validation.cpp +++ b/src/util/validation.cpp @@ -8,16 +8,18 @@ #include <consensus/validation.h> #include <tinyformat.h> -/** Convert ValidationState to a human-readable message for logging */ std::string FormatStateMessage(const ValidationState &state) { if (state.IsValid()) { return "Valid"; } - return strprintf("%s%s", - state.GetRejectReason(), - state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage()); + const std::string debug_message = state.GetDebugMessage(); + if (!debug_message.empty()) { + return strprintf("%s, %s", state.GetRejectReason(), debug_message); + } + + return state.GetRejectReason(); } const std::string strMessageMagic = "Bitcoin Signed Message:\n"; |