aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJeffrey Czyz <[email protected]>2020-01-03 11:38:44 -0800
committerJeffrey Czyz <[email protected]>2020-01-03 11:38:44 -0800
commit6edebacb2191373e76d79a4972d6192300976096 (patch)
treee2c49ba8ead3a5689ac266aa7849ecf5f5e03e13 /src/util
parentFormat CValidationState properly in all cases (diff)
downloaddiscoin-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.cpp10
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";