mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 19:23:26 -03:00
Optionally populate BlockAndHeaderTipInfo during AppInitMain
This commit is contained in:
parent
b354a1480a
commit
d42cb79068
2 changed files with 15 additions and 2 deletions
12
src/init.cpp
12
src/init.cpp
|
@ -24,6 +24,7 @@
|
||||||
#include <index/blockfilterindex.h>
|
#include <index/blockfilterindex.h>
|
||||||
#include <index/txindex.h>
|
#include <index/txindex.h>
|
||||||
#include <interfaces/chain.h>
|
#include <interfaces/chain.h>
|
||||||
|
#include <interfaces/node.h>
|
||||||
#include <key.h>
|
#include <key.h>
|
||||||
#include <miner.h>
|
#include <miner.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
|
@ -1242,7 +1243,7 @@ bool AppInitLockDataDirectory()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppInitMain(const util::Ref& context, NodeContext& node)
|
bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
// ********************************************************* Step 4a: application initialization
|
// ********************************************************* Step 4a: application initialization
|
||||||
|
@ -1877,6 +1878,15 @@ bool AppInitMain(const util::Ref& context, NodeContext& node)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
LogPrintf("block tree size = %u\n", chainman.BlockIndex().size());
|
LogPrintf("block tree size = %u\n", chainman.BlockIndex().size());
|
||||||
chain_active_height = chainman.ActiveChain().Height();
|
chain_active_height = chainman.ActiveChain().Height();
|
||||||
|
if (tip_info) {
|
||||||
|
tip_info->block_height = chain_active_height;
|
||||||
|
tip_info->block_time = chainman.ActiveChain().Tip() ? chainman.ActiveChain().Tip()->GetBlockTime() : Params().GenesisBlock().GetBlockTime();
|
||||||
|
tip_info->verification_progress = GuessVerificationProgress(Params().TxData(), chainman.ActiveChain().Tip());
|
||||||
|
}
|
||||||
|
if (tip_info && ::pindexBestHeader) {
|
||||||
|
tip_info->header_height = ::pindexBestHeader->nHeight;
|
||||||
|
tip_info->header_time = ::pindexBestHeader->GetBlockTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LogPrintf("nBestHeight = %d\n", chain_active_height);
|
LogPrintf("nBestHeight = %d\n", chain_active_height);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
|
||||||
struct NodeContext;
|
struct NodeContext;
|
||||||
|
namespace interfaces {
|
||||||
|
struct BlockAndHeaderTipInfo;
|
||||||
|
}
|
||||||
namespace boost {
|
namespace boost {
|
||||||
class thread_group;
|
class thread_group;
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@ -54,7 +57,7 @@ bool AppInitLockDataDirectory();
|
||||||
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
|
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
|
||||||
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
|
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
|
||||||
*/
|
*/
|
||||||
bool AppInitMain(const util::Ref& context, NodeContext& node);
|
bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register all arguments with the ArgsManager
|
* Register all arguments with the ArgsManager
|
||||||
|
|
Loading…
Add table
Reference in a new issue