Skip to content

Commit c991cea

Browse files
committed
Remove processNewBlock() from mining interface
processNewBlock was added in 7b4d324, but became unnecessary with the introduction of interfaces::BlockTemplate::submitSolution in 7b4d324. getTransactionsUpdated() is only needed by the implementation of waitFeesChanged() (not yet part of the interface).
1 parent 9a47852 commit c991cea

File tree

4 files changed

+5
-23
lines changed

4 files changed

+5
-23
lines changed

src/interfaces/mining.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,6 @@ class Mining
9393
*/
9494
virtual std::unique_ptr<BlockTemplate> createNewBlock(const node::BlockCreateOptions& options = {}) = 0;
9595

96-
/**
97-
* Processes new block. A valid new block is automatically relayed to peers.
98-
*
99-
* @param[in] block The block we want to process.
100-
* @param[out] new_block A boolean which is set to indicate if the block was first received via this call
101-
* @returns If the block was processed, independently of block validity
102-
*/
103-
virtual bool processNewBlock(const std::shared_ptr<const CBlock>& block, bool* new_block) = 0;
104-
10596
//! Get internal node context. Useful for RPC and testing,
10697
//! but not accessible across processes.
10798
virtual node::NodeContext* context() { return nullptr; }

src/ipc/capnp/mining.capnp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ interface Mining $Proxy.wrap("interfaces::Mining") {
1818
getTip @2 (context :Proxy.Context) -> (result: Common.BlockRef, hasResult: Bool);
1919
waitTipChanged @3 (context :Proxy.Context, currentTip: Data, timeout: Float64) -> (result: Common.BlockRef);
2020
createNewBlock @4 (options: BlockCreateOptions) -> (result: BlockTemplate);
21-
processNewBlock @5 (context :Proxy.Context, block: Data) -> (newBlock: Bool, result: Bool);
2221
}
2322

2423
interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {

src/node/interfaces.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -979,11 +979,6 @@ class MinerImpl : public Mining
979979
return BlockRef{chainman().ActiveChain().Tip()->GetBlockHash(), chainman().ActiveChain().Tip()->nHeight};
980980
}
981981

982-
bool processNewBlock(const std::shared_ptr<const CBlock>& block, bool* new_block) override
983-
{
984-
return chainman().ProcessNewBlock(block, /*force_processing=*/true, /*min_pow_checked=*/true, /*new_block=*/new_block);
985-
}
986-
987982
std::unique_ptr<BlockTemplate> createNewBlock(const BlockCreateOptions& options) override
988983
{
989984
BlockAssembler::Options assemble_options{options};

src/rpc/mining.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static RPCHelpMan getnetworkhashps()
131131
};
132132
}
133133

134-
static bool GenerateBlock(ChainstateManager& chainman, Mining& miner, CBlock&& block, uint64_t& max_tries, std::shared_ptr<const CBlock>& block_out, bool process_new_block)
134+
static bool GenerateBlock(ChainstateManager& chainman, CBlock&& block, uint64_t& max_tries, std::shared_ptr<const CBlock>& block_out, bool process_new_block)
135135
{
136136
block_out.reset();
137137
block.hashMerkleRoot = BlockMerkleRoot(block);
@@ -151,7 +151,7 @@ static bool GenerateBlock(ChainstateManager& chainman, Mining& miner, CBlock&& b
151151

152152
if (!process_new_block) return true;
153153

154-
if (!miner.processNewBlock(block_out, nullptr)) {
154+
if (!chainman.ProcessNewBlock(block_out, /*force_processing=*/true, /*min_pow_checked=*/true, nullptr)) {
155155
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
156156
}
157157

@@ -166,7 +166,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, Mining& miner, const
166166
CHECK_NONFATAL(block_template);
167167

168168
std::shared_ptr<const CBlock> block_out;
169-
if (!GenerateBlock(chainman, miner, block_template->getBlock(), nMaxTries, block_out, /*process_new_block=*/true)) {
169+
if (!GenerateBlock(chainman, block_template->getBlock(), nMaxTries, block_out, /*process_new_block=*/true)) {
170170
break;
171171
}
172172

@@ -394,7 +394,7 @@ static RPCHelpMan generateblock()
394394
std::shared_ptr<const CBlock> block_out;
395395
uint64_t max_tries{DEFAULT_MAX_TRIES};
396396

397-
if (!GenerateBlock(chainman, miner, std::move(block), max_tries, block_out, process_new_block) || !block_out) {
397+
if (!GenerateBlock(chainman, std::move(block), max_tries, block_out, process_new_block) || !block_out) {
398398
throw JSONRPCError(RPC_MISC_ERROR, "Failed to make block.");
399399
}
400400

@@ -1034,13 +1034,10 @@ static RPCHelpMan submitblock()
10341034
}
10351035
}
10361036

1037-
NodeContext& node = EnsureAnyNodeContext(request.context);
1038-
Mining& miner = EnsureMining(node);
1039-
10401037
bool new_block;
10411038
auto sc = std::make_shared<submitblock_StateCatcher>(block.GetHash());
10421039
CHECK_NONFATAL(chainman.m_options.signals)->RegisterSharedValidationInterface(sc);
1043-
bool accepted = miner.processNewBlock(blockptr, /*new_block=*/&new_block);
1040+
bool accepted = chainman.ProcessNewBlock(blockptr, /*force_processing=*/true, /*min_pow_checked=*/true, /*new_block=*/&new_block);
10441041
CHECK_NONFATAL(chainman.m_options.signals)->UnregisterSharedValidationInterface(sc);
10451042
if (!new_block && accepted) {
10461043
return "duplicate";

0 commit comments

Comments
 (0)