Skip to content

Commit ed4462c

Browse files
committed
init: start indexes sync earlier
The mempool load can take a while, and it is not needed for the indexes' synchronization. Also, having the mempool load function call inside 'blockstorage.cpp' wasn't structurally correct.
1 parent 79e8247 commit ed4462c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/init.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16571657
}
16581658

16591659
chainman.m_load_block = std::thread(&util::TraceThread, "loadblk", [=, &chainman, &args] {
1660-
ThreadImport(chainman, vImportFiles, ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{});
1660+
// Import blocks
1661+
ThreadImport(chainman, vImportFiles);
1662+
// Load mempool from disk
1663+
chainman.ActiveChainstate().LoadMempool(ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{});
16611664
});
16621665

16631666
// Wait for genesis block to be processed

src/node/blockstorage.cpp

Lines changed: 2 additions & 2 deletions
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, const fs::path& mempool_path)
871+
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles)
872872
{
873873
ScheduleBatchPriority();
874874

@@ -939,7 +939,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
939939
return;
940940
}
941941
} // End scope of ImportingNow
942-
chainman.ActiveChainstate().LoadMempool(mempool_path);
942+
943943
g_indexes_ready_to_sync = true;
944944
}
945945
} // namespace node

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, const fs::path& mempool_path);
258+
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles);
259259
} // namespace node
260260

261261
#endif // BITCOIN_NODE_BLOCKSTORAGE_H

0 commit comments

Comments
 (0)