@@ -129,7 +129,7 @@ static RPCHelpMan getnetworkhashps()
129129 };
130130}
131131
132- static bool GenerateBlock (ChainstateManager& chainman, CBlock& block, uint64_t & max_tries, std::shared_ptr<const CBlock>& block_out, bool process_new_block)
132+ static bool GenerateBlock (ChainstateManager& chainman, Mining& miner, CBlock& block, uint64_t & max_tries, std::shared_ptr<const CBlock>& block_out, bool process_new_block)
133133{
134134 block_out.reset ();
135135 block.hashMerkleRoot = BlockMerkleRoot (block);
@@ -149,7 +149,7 @@ static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t&
149149
150150 if (!process_new_block) return true ;
151151
152- if (!chainman. ProcessNewBlock (block_out, /* force_processing= */ true , /* min_pow_checked= */ true , nullptr )) {
152+ if (!miner. processNewBlock (block_out, nullptr )) {
153153 throw JSONRPCError (RPC_INTERNAL_ERROR, " ProcessNewBlock, block not accepted" );
154154 }
155155
@@ -165,7 +165,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, Mining& miner, const
165165 throw JSONRPCError (RPC_INTERNAL_ERROR, " Couldn't create new block" );
166166
167167 std::shared_ptr<const CBlock> block_out;
168- if (!GenerateBlock (chainman, pblocktemplate->block , nMaxTries, block_out, /* process_new_block=*/ true )) {
168+ if (!GenerateBlock (chainman, miner, pblocktemplate->block , nMaxTries, block_out, /* process_new_block=*/ true )) {
169169 break ;
170170 }
171171
@@ -398,7 +398,7 @@ static RPCHelpMan generateblock()
398398 std::shared_ptr<const CBlock> block_out;
399399 uint64_t max_tries{DEFAULT_MAX_TRIES};
400400
401- if (!GenerateBlock (chainman, block, max_tries, block_out, process_new_block) || !block_out) {
401+ if (!GenerateBlock (chainman, miner, block, max_tries, block_out, process_new_block) || !block_out) {
402402 throw JSONRPCError (RPC_MISC_ERROR, " Failed to make block." );
403403 }
404404
@@ -1049,10 +1049,13 @@ static RPCHelpMan submitblock()
10491049 }
10501050 }
10511051
1052+ NodeContext& node = EnsureAnyNodeContext (request.context );
1053+ Mining& miner = EnsureMining (node);
1054+
10521055 bool new_block;
10531056 auto sc = std::make_shared<submitblock_StateCatcher>(block.GetHash ());
10541057 CHECK_NONFATAL (chainman.m_options .signals )->RegisterSharedValidationInterface (sc);
1055- bool accepted = chainman. ProcessNewBlock (blockptr, /* force_processing= */ true , /* min_pow_checked= */ true , /* new_block=*/ &new_block);
1058+ bool accepted = miner. processNewBlock (blockptr, /* new_block=*/ &new_block);
10561059 CHECK_NONFATAL (chainman.m_options .signals )->UnregisterSharedValidationInterface (sc);
10571060 if (!new_block && accepted) {
10581061 return " duplicate" ;
0 commit comments