diff options
| author | Jeffrey Czyz <[email protected]> | 2020-01-03 11:38:44 -0800 |
|---|---|---|
| committer | Jeffrey Czyz <[email protected]> | 2020-01-03 11:38:44 -0800 |
| commit | 6edebacb2191373e76d79a4972d6192300976096 (patch) | |
| tree | e2c49ba8ead3a5689ac266aa7849ecf5f5e03e13 /src/util | |
| parent | Format CValidationState properly in all cases (diff) | |
| download | discoin-6edebacb2191373e76d79a4972d6192300976096.tar.xz discoin-6edebacb2191373e76d79a4972d6192300976096.zip | |
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')
| -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 603db51d4..ed9c108bb 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"; |