mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-28 18:01:27 +02:00
interfaces: move getTip implementation to miner
This commit is contained in:
parent
720f201e65
commit
c39ca9d4f7
@ -966,10 +966,7 @@ public:
|
||||
|
||||
std::optional<BlockRef> getTip() override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
CBlockIndex* tip{chainman().ActiveChain().Tip()};
|
||||
if (!tip) return {};
|
||||
return BlockRef{tip->GetBlockHash(), tip->nHeight};
|
||||
return GetTip(chainman());
|
||||
}
|
||||
|
||||
std::optional<BlockRef> waitTipChanged(uint256 current_tip, MillisecondsDouble timeout) override
|
||||
|
@ -539,4 +539,12 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::optional<BlockRef> GetTip(ChainstateManager& chainman)
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
CBlockIndex* tip{chainman.ActiveChain().Tip()};
|
||||
if (!tip) return {};
|
||||
return BlockRef{tip->GetBlockHash(), tip->nHeight};
|
||||
}
|
||||
} // namespace node
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifndef BITCOIN_NODE_MINER_H
|
||||
#define BITCOIN_NODE_MINER_H
|
||||
|
||||
#include <interfaces/types.h>
|
||||
#include <node/types.h>
|
||||
#include <policy/policy.h>
|
||||
#include <primitives/block.h>
|
||||
@ -31,6 +32,8 @@ class ChainstateManager;
|
||||
|
||||
namespace Consensus { struct Params; };
|
||||
|
||||
using interfaces::BlockRef;
|
||||
|
||||
namespace node {
|
||||
class KernelNotifications;
|
||||
|
||||
@ -245,6 +248,9 @@ std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainma
|
||||
const std::unique_ptr<CBlockTemplate>& block_template,
|
||||
const BlockWaitOptions& options,
|
||||
const BlockAssembler::Options& assemble_options);
|
||||
|
||||
/* Locks cs_main and returns the block hash and block height of the active chain if it exists; otherwise, returns nullopt.*/
|
||||
std::optional<BlockRef> GetTip(ChainstateManager& chainman);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_MINER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user