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
966
966
967
967
std::optional<BlockRef> getTip () override
968
968
{
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 ());
973
970
}
974
971
975
972
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
539
539
540
540
return nullptr ;
541
541
}
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
+ }
542
550
} // namespace node
Original file line number Diff line number Diff line change 6
6
#ifndef BITCOIN_NODE_MINER_H
7
7
#define BITCOIN_NODE_MINER_H
8
8
9
+ #include < interfaces/types.h>
9
10
#include < node/types.h>
10
11
#include < policy/policy.h>
11
12
#include < primitives/block.h>
@@ -31,6 +32,8 @@ class ChainstateManager;
31
32
32
33
namespace Consensus { struct Params ; };
33
34
35
+ using interfaces::BlockRef;
36
+
34
37
namespace node {
35
38
class KernelNotifications ;
36
39
@@ -245,6 +248,9 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
245
248
const std::unique_ptr<CBlockTemplate>& block_template,
246
249
const BlockWaitOptions& options,
247
250
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);
248
254
} // namespace node
249
255
250
256
#endif // BITCOIN_NODE_MINER_H
You can’t perform that action at this time.
0 commit comments