mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
refactor: testBlockValidity make out argument last
This commit is contained in:
parent
83a9bef0e2
commit
75ce7637ad
3 changed files with 6 additions and 5 deletions
|
@ -45,6 +45,7 @@ public:
|
||||||
* @returns a block template
|
* @returns a block template
|
||||||
*/
|
*/
|
||||||
virtual std::unique_ptr<node::CBlockTemplate> createNewBlock(const CScript& script_pub_key, bool use_mempool = true) = 0;
|
virtual std::unique_ptr<node::CBlockTemplate> createNewBlock(const CScript& script_pub_key, bool use_mempool = true) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes new block. A valid new block is automatically relayed to peers.
|
* Processes new block. A valid new block is automatically relayed to peers.
|
||||||
*
|
*
|
||||||
|
@ -63,12 +64,12 @@ public:
|
||||||
* Only works on top of our current best block.
|
* Only works on top of our current best block.
|
||||||
* Does not check proof-of-work.
|
* Does not check proof-of-work.
|
||||||
*
|
*
|
||||||
* @param[out] state details of why a block failed to validate
|
|
||||||
* @param[in] block the block to validate
|
* @param[in] block the block to validate
|
||||||
* @param[in] check_merkle_root call CheckMerkleRoot()
|
* @param[in] check_merkle_root call CheckMerkleRoot()
|
||||||
|
* @param[out] state details of why a block failed to validate
|
||||||
* @returns false if any of the checks fail
|
* @returns false if any of the checks fail
|
||||||
*/
|
*/
|
||||||
virtual bool testBlockValidity(BlockValidationState& state, const CBlock& block, bool check_merkle_root = true) = 0;
|
virtual bool testBlockValidity(const CBlock& block, bool check_merkle_root, BlockValidationState& state) = 0;
|
||||||
|
|
||||||
//! Get internal node context. Useful for RPC and testing,
|
//! Get internal node context. Useful for RPC and testing,
|
||||||
//! but not accessible across processes.
|
//! but not accessible across processes.
|
||||||
|
|
|
@ -870,7 +870,7 @@ public:
|
||||||
return context()->mempool->GetTransactionsUpdated();
|
return context()->mempool->GetTransactionsUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool testBlockValidity(BlockValidationState& state, const CBlock& block, bool check_merkle_root) override
|
bool testBlockValidity(const CBlock& block, bool check_merkle_root, BlockValidationState& state) override
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
return TestBlockValidity(state, chainman().GetParams(), chainman().ActiveChainstate(), block, chainman().ActiveChain().Tip(), /*fCheckPOW=*/false, check_merkle_root);
|
return TestBlockValidity(state, chainman().GetParams(), chainman().ActiveChainstate(), block, chainman().ActiveChain().Tip(), /*fCheckPOW=*/false, check_merkle_root);
|
||||||
|
|
|
@ -390,7 +390,7 @@ static RPCHelpMan generateblock()
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!miner.testBlockValidity(state, block, /*check_merkle_root=*/false)) {
|
if (!miner.testBlockValidity(block, /*check_merkle_root=*/false, state)) {
|
||||||
throw JSONRPCError(RPC_VERIFY_ERROR, strprintf("testBlockValidity failed: %s", state.ToString()));
|
throw JSONRPCError(RPC_VERIFY_ERROR, strprintf("testBlockValidity failed: %s", state.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
return "inconclusive-not-best-prevblk";
|
return "inconclusive-not-best-prevblk";
|
||||||
}
|
}
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
miner.testBlockValidity(state, block);
|
miner.testBlockValidity(block, /*check_merkle_root=*/true, state);
|
||||||
return BIP22ValidationResult(state);
|
return BIP22ValidationResult(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue