Skip to content

Commit 6edebac

Browse files
committed
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).
1 parent 72f3227 commit 6edebac

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/util/validation.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88
#include <consensus/validation.h>
99
#include <tinyformat.h>
1010

11-
/** Convert ValidationState to a human-readable message for logging */
1211
std::string FormatStateMessage(const ValidationState &state)
1312
{
1413
if (state.IsValid()) {
1514
return "Valid";
1615
}
1716

18-
return strprintf("%s%s",
19-
state.GetRejectReason(),
20-
state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage());
17+
const std::string debug_message = state.GetDebugMessage();
18+
if (!debug_message.empty()) {
19+
return strprintf("%s, %s", state.GetRejectReason(), debug_message);
20+
}
21+
22+
return state.GetRejectReason();
2123
}
2224

2325
const std::string strMessageMagic = "Bitcoin Signed Message:\n";

0 commit comments

Comments
 (0)