Changeset View
Changeset View
Standalone View
Standalone View
src/util/validation.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2019 The Bitcoin Core developers | // Copyright (c) 2009-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <util/validation.h> | #include <util/validation.h> | ||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
/** Convert ValidationState to a human-readable message for logging */ | |||||
std::string FormatStateMessage(const ValidationState &state) { | std::string FormatStateMessage(const ValidationState &state) { | ||||
return strprintf( | if (state.IsValid()) { | ||||
"%s%s (code %i)", state.GetRejectReason(), | return "Valid"; | ||||
state.GetDebugMessage().empty() ? "" : ", " + state.GetDebugMessage(), | } | ||||
const std::string debug_message = state.GetDebugMessage(); | |||||
if (!debug_message.empty()) { | |||||
return strprintf("%s, %s (code %i)", state.GetRejectReason(), | |||||
debug_message, state.GetRejectCode()); | |||||
} | |||||
return strprintf("%s (code %i)", state.GetRejectReason(), | |||||
state.GetRejectCode()); | state.GetRejectCode()); | ||||
} | } | ||||
const std::string strMessageMagic = "Bitcoin Signed Message:\n"; | const std::string strMessageMagic = "Bitcoin Signed Message:\n"; |