From d0f1c29cd5c4dc4b55cca5403bb1ff125ebc2caa Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Mon, 20 Sep 2021 17:08:18 -0400 Subject: [PATCH] node/chainstate: Decouple from GetTimeMillis Summary: ``` ...instead just move it out ``` Partial backport of [[https://github.com/bitcoin/bitcoin/pull/23280 | core#23280]]: https://github.com/bitcoin/bitcoin/pull/23280/commits/cbac28b72f5b831f6f84b7628f73e85627af3d94 Depends on D12555. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D12556 --- src/init.cpp | 6 ++++++ src/node/chainstate.cpp | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index b38987f3c8..cb5a1950ed 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2654,11 +2654,17 @@ bool AppInitMain(Config &config, RPCServer &rpcServer, uiInterface.InitMessage(_("Loading block index...").translated); + const int64_t load_block_index_start_time = GetTimeMillis(); + if (!LoadChainstate(fLoaded, strLoadError, fReset, chainman, node, fPruneMode, config, args, fReindexChainState, nBlockTreeDBCache, nCoinDBCache, nCoinCacheUsage)) { return false; } + if (fLoaded) { + LogPrintf(" block index %15dms\n", + GetTimeMillis() - load_block_index_start_time); + } if (!fLoaded && !ShutdownRequested()) { // first suggest a reindex diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 2e5a8f7880..6b90ca5691 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -31,7 +31,6 @@ bool LoadChainstate(bool &fLoaded, bilingual_str &strLoadError, bool fReset, do { bool failed_verification = false; - const int64_t load_block_index_start_time = GetTimeMillis(); try { LOCK(cs_main); chainman.InitializeChainstate(Assert(node.mempool.get())); @@ -215,8 +214,6 @@ bool LoadChainstate(bool &fLoaded, bilingual_str &strLoadError, bool fReset, if (!failed_verification) { fLoaded = true; - LogPrintf(" block index %15dms\n", - GetTimeMillis() - load_block_index_start_time); } } while (false);