File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -966,10 +966,7 @@ class MinerImpl : public Mining
966966
967967 std::optional<BlockRef> getTip () override
968968 {
969- LOCK (::cs_main);
970- CBlockIndex* tip{chainman ().ActiveChain ().Tip ()};
971- if (!tip) return {};
972- return BlockRef{tip->GetBlockHash (), tip->nHeight };
969+ return GetTip (chainman ());
973970 }
974971
975972 std::optional<BlockRef> waitTipChanged (uint256 current_tip, MillisecondsDouble timeout) override
Original file line number Diff line number Diff line change @@ -539,4 +539,12 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
539539
540540 return nullptr ;
541541}
542+
543+ std::optional<BlockRef> GetTip (ChainstateManager& chainman)
544+ {
545+ LOCK (::cs_main);
546+ CBlockIndex* tip{chainman.ActiveChain ().Tip ()};
547+ if (!tip) return {};
548+ return BlockRef{tip->GetBlockHash (), tip->nHeight };
549+ }
542550} // namespace node
Original file line number Diff line number Diff line change 66#ifndef BITCOIN_NODE_MINER_H
77#define BITCOIN_NODE_MINER_H
88
9+ #include < interfaces/types.h>
910#include < node/types.h>
1011#include < policy/policy.h>
1112#include < primitives/block.h>
@@ -31,6 +32,8 @@ class ChainstateManager;
3132
3233namespace Consensus { struct Params ; };
3334
35+ using interfaces::BlockRef;
36+
3437namespace node {
3538class KernelNotifications ;
3639
@@ -245,6 +248,9 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
245248 const std::unique_ptr<CBlockTemplate>& block_template,
246249 const BlockWaitOptions& options,
247250 const BlockAssembler::Options& assemble_options);
251+
252+ /* Locks cs_main and returns the block hash and block height of the active chain if it exists; otherwise, returns nullopt.*/
253+ std::optional<BlockRef> GetTip (ChainstateManager& chainman);
248254} // namespace node
249255
250256#endif // BITCOIN_NODE_MINER_H
You can’t perform that action at this time.
0 commit comments