@@ -129,7 +129,7 @@ static RPCHelpMan getnetworkhashps()
129
129
};
130
130
}
131
131
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)
133
133
{
134
134
block_out.reset ();
135
135
block.hashMerkleRoot = BlockMerkleRoot (block);
@@ -149,7 +149,7 @@ static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t&
149
149
150
150
if (!process_new_block) return true ;
151
151
152
- if (!chainman. ProcessNewBlock (block_out, /* force_processing= */ true , /* min_pow_checked= */ true , nullptr )) {
152
+ if (!miner. processNewBlock (block_out, nullptr )) {
153
153
throw JSONRPCError (RPC_INTERNAL_ERROR, " ProcessNewBlock, block not accepted" );
154
154
}
155
155
@@ -165,7 +165,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, Mining& miner, const
165
165
throw JSONRPCError (RPC_INTERNAL_ERROR, " Couldn't create new block" );
166
166
167
167
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 )) {
169
169
break ;
170
170
}
171
171
@@ -398,7 +398,7 @@ static RPCHelpMan generateblock()
398
398
std::shared_ptr<const CBlock> block_out;
399
399
uint64_t max_tries{DEFAULT_MAX_TRIES};
400
400
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) {
402
402
throw JSONRPCError (RPC_MISC_ERROR, " Failed to make block." );
403
403
}
404
404
@@ -1049,10 +1049,13 @@ static RPCHelpMan submitblock()
1049
1049
}
1050
1050
}
1051
1051
1052
+ NodeContext& node = EnsureAnyNodeContext (request.context );
1053
+ Mining& miner = EnsureMining (node);
1054
+
1052
1055
bool new_block;
1053
1056
auto sc = std::make_shared<submitblock_StateCatcher>(block.GetHash ());
1054
1057
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);
1056
1059
CHECK_NONFATAL (chainman.m_options .signals )->UnregisterSharedValidationInterface (sc);
1057
1060
if (!new_block && accepted) {
1058
1061
return " duplicate" ;
0 commit comments