mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 10:12:28 +02:00
Merge #17399: validation: Templatize ValidationState instead of subclassing
10efc0487cTemplatize ValidationState instead of subclassing (Jeffrey Czyz)10e85d4adcRemove ValidationState's constructor (Jeffrey Czyz)0aed17ef28Refactor FormatStateMessage into ValidationState (Jeffrey Czyz) Pull request description: This removes boilerplate code in the subclasses which otherwise only differ by the result type. The subclassing was introduced ina27a295. ACKs for top commit: MarcoFalke: ACK10efc0487c🐱 ajtowns: ACK10efc0487c-- looks good to me jonatack: ACK10efc048code review, build/tests green, nice cleanup Tree-SHA512: 765dd52dde7d49b9a5c6d99d97c96f4492673e2aed0b0604faa88db0308fa4500a26bf755cca0b896be283874096c215932e1110a2d01dc012cd36a5fce58a42
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
||||
// 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>
|
||||
|
||||
std::string FormatStateMessage(const ValidationState &state)
|
||||
{
|
||||
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();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_VALIDATION_H
|
||||
#define BITCOIN_UTIL_VALIDATION_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class ValidationState;
|
||||
|
||||
/** Convert ValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const ValidationState &state);
|
||||
|
||||
#endif // BITCOIN_UTIL_VALIDATION_H
|
||||
Reference in New Issue
Block a user