mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-07 13:18:43 +02:00
Refactor FormatStateMessage into ValidationState
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include <undo.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <util/validation.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <warnings.h>
|
||||
@@ -1486,7 +1485,7 @@ static UniValue preciousblock(const JSONRPCRequest& request)
|
||||
PreciousBlock(state, Params(), pblockindex);
|
||||
|
||||
if (!state.IsValid()) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
|
||||
}
|
||||
|
||||
return NullUniValue;
|
||||
@@ -1524,7 +1523,7 @@ static UniValue invalidateblock(const JSONRPCRequest& request)
|
||||
}
|
||||
|
||||
if (!state.IsValid()) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
|
||||
}
|
||||
|
||||
return NullUniValue;
|
||||
@@ -1561,7 +1560,7 @@ static UniValue reconsiderblock(const JSONRPCRequest& request)
|
||||
ActivateBestChain(state, Params());
|
||||
|
||||
if (!state.IsValid()) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
|
||||
}
|
||||
|
||||
return NullUniValue;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <util/fees.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <util/validation.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <versionbitsinfo.h>
|
||||
@@ -307,7 +306,7 @@ static UniValue BIP22ValidationResult(const BlockValidationState& state)
|
||||
return NullUniValue;
|
||||
|
||||
if (state.IsError())
|
||||
throw JSONRPCError(RPC_VERIFY_ERROR, FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_VERIFY_ERROR, state.ToString());
|
||||
if (state.IsInvalid())
|
||||
{
|
||||
std::string strRejectReason = state.GetRejectReason();
|
||||
@@ -823,7 +822,7 @@ static UniValue submitheader(const JSONRPCRequest& request)
|
||||
ProcessNewBlockHeaders({h}, state, Params());
|
||||
if (state.IsValid()) return NullUniValue;
|
||||
if (state.IsError()) {
|
||||
throw JSONRPCError(RPC_VERIFY_ERROR, FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_VERIFY_ERROR, state.ToString());
|
||||
}
|
||||
throw JSONRPCError(RPC_VERIFY_ERROR, state.GetRejectReason());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user