diff options
author | Sjors Provoost <sjors@sprovoost.nl> | 2024-06-25 13:33:35 +0200 |
---|---|---|
committer | Sjors Provoost <sjors@sprovoost.nl> | 2024-06-26 12:24:48 +0200 |
commit | 75ce7637ad75af890581660c0bb3565c3c03bd6c (patch) | |
tree | 4b2b91d13a8bc33083bef3b9df5d7bc7143ca089 | |
parent | 83a9bef0e2acad7655e23d30e1c52412f380d93d (diff) |
refactor: testBlockValidity make out argument last
-rw-r--r-- | src/interfaces/mining.h | 5 | ||||
-rw-r--r-- | src/node/interfaces.cpp | 2 | ||||
-rw-r--r-- | src/rpc/mining.cpp | 4 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h index 1f603399bf..bc98448833 100644 --- a/src/interfaces/mining.h +++ b/src/interfaces/mining.h @@ -45,6 +45,7 @@ public: * @returns a block template */ 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. * @@ -63,12 +64,12 @@ public: * Only works on top of our current best block. * 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] check_merkle_root call CheckMerkleRoot() + * @param[out] state details of why a block failed to validate * @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, //! but not accessible across processes. diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index e0bab6e22e..931b98e59c 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -870,7 +870,7 @@ public: 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); return TestBlockValidity(state, chainman().GetParams(), chainman().ActiveChainstate(), block, chainman().ActiveChain().Tip(), /*fCheckPOW=*/false, check_merkle_root); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 2b93c18965..fe91d1ed89 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -390,7 +390,7 @@ static RPCHelpMan generateblock() LOCK(cs_main); 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())); } } @@ -713,7 +713,7 @@ static RPCHelpMan getblocktemplate() return "inconclusive-not-best-prevblk"; } BlockValidationState state; - miner.testBlockValidity(state, block); + miner.testBlockValidity(block, /*check_merkle_root=*/true, state); return BIP22ValidationResult(state); } |