mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-04 04:32:20 +02:00
Format CValidationState properly in all cases
FormatValidationMessage does not properly handle the case where CValidationState::IsValid() returns true. Use "Valid" for the state in this case.
This commit is contained in:
@ -5,15 +5,20 @@
|
||||
|
||||
#include <util/validation.h>
|
||||
|
||||
#include <consensus/validation.h>
|
||||
#include <tinyformat.h>
|
||||
|
||||
/** Convert ValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const ValidationState &state)
|
||||
{
|
||||
return strprintf("%s%s",
|
||||
state.GetRejectReason(),
|
||||
state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage());
|
||||
if (state.IsValid()) {
|
||||
return "Valid";
|
||||
}
|
||||
|
||||
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";
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef BITCOIN_UTIL_VALIDATION_H
|
||||
#define BITCOIN_UTIL_VALIDATION_H
|
||||
|
||||
#include <string>
|
||||
#include <consensus/validation.h>
|
||||
|
||||
class ValidationState;
|
||||
#include <string>
|
||||
|
||||
/** Convert ValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const ValidationState &state);
|
||||
|
Reference in New Issue
Block a user