2019-04-02 17:03:37 -04:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2020-01-15 02:17:38 +07:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2019-04-02 17:03:37 -04:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
|
|
#include <util/validation.h>
|
|
|
|
|
|
|
|
|
|
#include <consensus/validation.h>
|
|
|
|
|
#include <tinyformat.h>
|
|
|
|
|
|
2019-10-24 11:35:42 -04:00
|
|
|
std::string FormatStateMessage(const ValidationState &state)
|
2019-04-02 17:03:37 -04:00
|
|
|
{
|
2020-01-03 11:32:22 -08:00
|
|
|
if (state.IsValid()) {
|
|
|
|
|
return "Valid";
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-03 11:38:44 -08:00
|
|
|
const std::string debug_message = state.GetDebugMessage();
|
|
|
|
|
if (!debug_message.empty()) {
|
|
|
|
|
return strprintf("%s, %s", state.GetRejectReason(), debug_message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return state.GetRejectReason();
|
2019-04-02 17:03:37 -04:00
|
|
|
}
|