Skip to content

Commit 0457510

Browse files
committed
scripted-diff: rename 'loadblk' thread name to 'initload'
The thread does not only load blocks, it loads the mempool and, in a future commit, will start the indexes as well. Also, renamed the 'ThreadImport' function to 'ImportBlocks' And the 'm_load_block' class member to 'm_thread_load'. -BEGIN VERIFY SCRIPT- sed -i "s/ThreadImport/ImportBlocks/g" $(git grep -l ThreadImport -- ':!/doc/') sed -i "s/loadblk/initload/g" $(git grep -l loadblk -- ':!/doc/release-notes/') sed -i "s/m_load_block/m_thread_load/g" $(git grep -l m_load_block) -END VERIFY SCRIPT-
1 parent ed4462c commit 0457510

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

doc/developer-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ Threads
621621
: Started from `main()` in `bitcoind.cpp`. Responsible for starting up and
622622
shutting down the application.
623623

624-
- [ThreadImport (`b-loadblk`)](https://doxygen.bitcoincore.org/namespacenode.html#ab4305679079866f0f420f7dbf278381d)
624+
- [ThreadImport (`b-initload`)](https://doxygen.bitcoincore.org/namespacenode.html#ab4305679079866f0f420f7dbf278381d)
625625
: Loads blocks from `blk*.dat` files or `-loadblock=<file>` on startup.
626626

627627
- [CCheckQueue::Loop (`b-scriptch.x`)](https://doxygen.bitcoincore.org/class_c_check_queue.html#a6e7fa51d3a25e7cb65446d4b50e6a987)

src/bitcoin-chainstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int main(int argc, char* argv[])
287287
// Without this precise shutdown sequence, there will be a lot of nullptr
288288
// dereferencing and UB.
289289
scheduler.stop();
290-
if (chainman.m_load_block.joinable()) chainman.m_load_block.join();
290+
if (chainman.m_thread_load.joinable()) chainman.m_thread_load.join();
291291
StopScriptCheckWorkerThreads();
292292

293293
GetMainSignals().FlushBackgroundCallbacks();

src/init.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ using node::LoadChainstate;
131131
using node::MempoolPath;
132132
using node::NodeContext;
133133
using node::ShouldPersistMempool;
134-
using node::ThreadImport;
134+
using node::ImportBlocks;
135135
using node::VerifyLoadedChainstate;
136136

137137
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
@@ -268,7 +268,7 @@ void Shutdown(NodeContext& node)
268268
// After everything has been shut down, but before things get flushed, stop the
269269
// CScheduler/checkqueue, scheduler and load block thread.
270270
if (node.scheduler) node.scheduler->stop();
271-
if (node.chainman && node.chainman->m_load_block.joinable()) node.chainman->m_load_block.join();
271+
if (node.chainman && node.chainman->m_thread_load.joinable()) node.chainman->m_thread_load.join();
272272
StopScriptCheckWorkerThreads();
273273

274274
// After the threads that potentially access these pointers have been stopped,
@@ -1545,7 +1545,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15451545

15461546
// ********************************************************* Step 8: start indexers
15471547

1548-
// If reindex-chainstate was specified, delay syncing indexes until ThreadImport has reindexed the chain
1548+
// If reindex-chainstate was specified, delay syncing indexes until ImportBlocks has reindexed the chain
15491549
if (!fReindexChainState) g_indexes_ready_to_sync = true;
15501550
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
15511551
auto result{WITH_LOCK(cs_main, return CheckLegacyTxindex(*Assert(chainman.m_blockman.m_block_tree_db)))};
@@ -1656,9 +1656,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16561656
vImportFiles.push_back(fs::PathFromString(strFile));
16571657
}
16581658

1659-
chainman.m_load_block = std::thread(&util::TraceThread, "loadblk", [=, &chainman, &args] {
1659+
chainman.m_thread_load = std::thread(&util::TraceThread, "initload", [=, &chainman, &args] {
16601660
// Import blocks
1661-
ThreadImport(chainman, vImportFiles);
1661+
ImportBlocks(chainman, vImportFiles);
16621662
// Load mempool from disk
16631663
chainman.ActiveChainstate().LoadMempool(ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{});
16641664
});
@@ -1667,7 +1667,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16671667
{
16681668
WAIT_LOCK(g_genesis_wait_mutex, lock);
16691669
// We previously could hang here if StartShutdown() is called prior to
1670-
// ThreadImport getting started, so instead we just wait on a timer to
1670+
// ImportBlocks getting started, so instead we just wait on a timer to
16711671
// check ShutdownRequested() regularly.
16721672
while (!fHaveGenesis && !ShutdownRequested()) {
16731673
g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500));

src/node/blockstorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ class ImportingNow
868868
}
869869
};
870870

871-
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles)
871+
void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFiles)
872872
{
873873
ScheduleBatchPriority();
874874

src/node/blockstorage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class BlockManager
255255
void CleanupBlockRevFiles() const;
256256
};
257257

258-
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles);
258+
void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFiles);
259259
} // namespace node
260260

261261
#endif // BITCOIN_NODE_BLOCKSTORAGE_H

src/node/chainstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static ChainstateLoadResult CompleteChainstateInitialization(
8282
// At this point blocktree args are consistent with what's on disk.
8383
// If we're not mid-reindex (based on disk + args), add a genesis block on disk
8484
// (otherwise we use the one already on disk).
85-
// This is called again in ThreadImport after the reindex completes.
85+
// This is called again in ImportBlocks after the reindex completes.
8686
if (!fReindex && !chainman.ActiveChainstate().LoadGenesisBlock()) {
8787
return {ChainstateLoadStatus::FAILURE, _("Error initializing block database")};
8888
}

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ class ChainstateManager
987987

988988
const util::SignalInterrupt& m_interrupt;
989989
const Options m_options;
990-
std::thread m_load_block;
990+
std::thread m_thread_load;
991991
//! A single BlockManager instance is shared across each constructed
992992
//! chainstate to avoid duplicating block metadata.
993993
node::BlockManager m_blockman;

test/functional/feature_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def check_clean_start():
7171
b'init message: Starting network threads',
7272
b'net thread start',
7373
b'addcon thread start',
74-
b'loadblk thread start',
74+
b'initload thread start',
7575
b'txindex thread start',
7676
b'block filter index thread start',
7777
b'coinstatsindex thread start',

test/functional/test_framework/test_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def wait_for_rpc_connection(self):
250250
# Wait for the node to finish reindex, block import, and
251251
# loading the mempool. Usually importing happens fast or
252252
# even "immediate" when the node is started. However, there
253-
# is no guarantee and sometimes ThreadImport might finish
253+
# is no guarantee and sometimes ImportBlocks might finish
254254
# later. This is going to cause intermittent test failures,
255255
# because generally the tests assume the node is fully
256256
# ready after being started.

0 commit comments

Comments
 (0)