Skip to content

Commit

Permalink
Refactor FormatStateMessage for clarity
Browse files Browse the repository at this point in the history
All cases of CValidationState were condensed into one strprintf call.
This is no longer suitable as more cases are added (e.g., IsValid).
  • Loading branch information
jkczyz authored and random-zebra committed Sep 10, 2021
1 parent b5d0ba9 commit 97d9633
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/util/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ std::string FormatStateMessage(const CValidationState& state)
return "Valid";
}

return strprintf("%s%s",
state.GetRejectReason(),
state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage(),
state.GetRejectCode());
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 = "DarkNet Signed Message:\n";

0 comments on commit 97d9633

Please sign in to comment.