Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864734
D12511.id36341.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D12511.id36341.diff
View Options
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -114,6 +114,7 @@
std::unique_ptr<CBlockTreeDB> m_block_tree_db GUARDED_BY(::cs_main);
+ bool WriteBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
bool LoadBlockIndexDB(ChainstateManager &chainman)
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -394,6 +394,29 @@
m_block_index.clear();
}
+bool BlockManager::WriteBlockIndexDB() {
+ std::vector<std::pair<int, const CBlockFileInfo *>> vFiles;
+ vFiles.reserve(setDirtyFileInfo.size());
+ for (int i : setDirtyFileInfo) {
+ vFiles.push_back(std::make_pair(i, &vinfoBlockFile[i]));
+ }
+
+ setDirtyFileInfo.clear();
+
+ std::vector<const CBlockIndex *> vBlocks;
+ vBlocks.reserve(setDirtyBlockIndex.size());
+ for (const CBlockIndex *cbi : setDirtyBlockIndex) {
+ vBlocks.push_back(cbi);
+ }
+
+ setDirtyBlockIndex.clear();
+
+ if (!m_block_tree_db->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) {
+ return false;
+ }
+ return true;
+}
+
bool BlockManager::LoadBlockIndexDB(ChainstateManager &chainman) {
if (!LoadBlockIndex(::Params().GetConsensus(), chainman)) {
return false;
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2059,24 +2059,7 @@
LOG_TIME_MILLIS_WITH_CATEGORY("write block index to disk",
BCLog::BENCH);
- std::vector<std::pair<int, const CBlockFileInfo *>> vFiles;
- vFiles.reserve(setDirtyFileInfo.size());
- for (int i : setDirtyFileInfo) {
- vFiles.push_back(std::make_pair(i, &vinfoBlockFile[i]));
- }
-
- setDirtyFileInfo.clear();
-
- std::vector<const CBlockIndex *> vBlocks;
- vBlocks.reserve(setDirtyBlockIndex.size());
- for (const CBlockIndex *cbi : setDirtyBlockIndex) {
- vBlocks.push_back(cbi);
- }
-
- setDirtyBlockIndex.clear();
-
- if (!m_blockman.m_block_tree_db->WriteBatchSync(
- vFiles, nLastBlockFile, vBlocks)) {
+ if (!m_blockman.WriteBlockIndexDB()) {
return AbortNode(
state, "Failed to write to block index database");
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 21:59 (20 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866013
Default Alt Text
D12511.id36341.diff (2 KB)
Attached To
D12511: move-only: Create WriteBlockIndexDB helper
Event Timeline
Log In to Comment