mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
[validation] Add CValidationState subclasses
Split CValidationState into TxValidationState and BlockValidationState to store validation results for transactions and blocks respectively.
This commit is contained in:
@@ -252,7 +252,7 @@ static UniValue prioritisetransaction(const JSONRPCRequest& request)
|
||||
|
||||
|
||||
// NOTE: Assumes a conclusive result; if result is inconclusive, it must be handled by caller
|
||||
static UniValue BIP22ValidationResult(const CValidationState& state)
|
||||
static UniValue BIP22ValidationResult(const BlockValidationState& state)
|
||||
{
|
||||
if (state.IsValid())
|
||||
return NullUniValue;
|
||||
@@ -401,7 +401,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
// TestBlockValidity only supports blocks built on the current Tip
|
||||
if (block.hashPrevBlock != pindexPrev->GetBlockHash())
|
||||
return "inconclusive-not-best-prevblk";
|
||||
CValidationState state;
|
||||
BlockValidationState state;
|
||||
TestBlockValidity(state, Params(), block, pindexPrev, false, true);
|
||||
return BIP22ValidationResult(state);
|
||||
}
|
||||
@@ -668,12 +668,12 @@ class submitblock_StateCatcher : public CValidationInterface
|
||||
public:
|
||||
uint256 hash;
|
||||
bool found;
|
||||
CValidationState state;
|
||||
BlockValidationState state;
|
||||
|
||||
explicit submitblock_StateCatcher(const uint256 &hashIn) : hash(hashIn), found(false), state() {}
|
||||
|
||||
protected:
|
||||
void BlockChecked(const CBlock& block, const CValidationState& stateIn) override {
|
||||
void BlockChecked(const CBlock& block, const BlockValidationState& stateIn) override {
|
||||
if (block.GetHash() != hash)
|
||||
return;
|
||||
found = true;
|
||||
@@ -772,7 +772,7 @@ static UniValue submitheader(const JSONRPCRequest& request)
|
||||
}
|
||||
}
|
||||
|
||||
CValidationState state;
|
||||
BlockValidationState state;
|
||||
ProcessNewBlockHeaders({h}, state, Params(), /* ppindex */ nullptr, /* first_invalid */ nullptr);
|
||||
if (state.IsValid()) return NullUniValue;
|
||||
if (state.IsError()) {
|
||||
|
||||
Reference in New Issue
Block a user