[validation] Add CValidationState subclasses

Split CValidationState into TxValidationState and BlockValidationState
to store validation results for transactions and blocks respectively.
This commit is contained in:
John Newbery
2019-10-24 11:35:42 -04:00
parent 48cb468ce3
commit a27a2957ed
33 changed files with 363 additions and 323 deletions

View File

@@ -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()) {