mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
init: Delay RPC block notif until warmup finished
This commit is contained in:
parent
94c0ceb29c
commit
f7aef8d331
10
src/init.cpp
10
src/init.cpp
@ -2400,7 +2400,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
|
|
||||||
// ********************************************************* Step 13: finished
|
// ********************************************************* Step 13: finished
|
||||||
|
|
||||||
|
// At this point, the RPC is "started", but still in warmup, which means it
|
||||||
|
// cannot yet be called. Before we make it callable, we need to make sure
|
||||||
|
// that the RPC's view of the best block is valid and consistent with
|
||||||
|
// ChainstateManager's ActiveTip.
|
||||||
|
//
|
||||||
|
// If we do not do this, RPC's view of the best block will be height=0 and
|
||||||
|
// hash=0x0. This will lead to erroroneous responses for things like
|
||||||
|
// waitforblockheight.
|
||||||
|
RPCNotifyBlockChange(chainman.ActiveTip());
|
||||||
SetRPCWarmupFinished();
|
SetRPCWarmupFinished();
|
||||||
|
|
||||||
uiInterface.InitMessage(_("Done loading").translated);
|
uiInterface.InitMessage(_("Done loading").translated);
|
||||||
|
|
||||||
for (const auto& client : node.chain_clients) {
|
for (const auto& client : node.chain_clients) {
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <chainparams.h> // for CChainParams
|
#include <chainparams.h> // for CChainParams
|
||||||
#include <deploymentstatus.h> // for DeploymentActiveAfter
|
#include <deploymentstatus.h> // for DeploymentActiveAfter
|
||||||
#include <rpc/blockchain.h> // for RPCNotifyBlockChange
|
|
||||||
#include <util/time.h> // for GetTime
|
#include <util/time.h> // for GetTime
|
||||||
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
||||||
#include <shutdown.h> // for ShutdownRequested
|
#include <shutdown.h> // for ShutdownRequested
|
||||||
@ -246,7 +245,6 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
|||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (CChainState* chainstate : chainman.GetAll()) {
|
||||||
if (!is_coinsview_empty(chainstate)) {
|
if (!is_coinsview_empty(chainstate)) {
|
||||||
const CBlockIndex* tip = chainstate->m_chain.Tip();
|
const CBlockIndex* tip = chainstate->m_chain.Tip();
|
||||||
RPCNotifyBlockChange(tip);
|
|
||||||
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {
|
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {
|
||||||
return ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE;
|
return ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user