Page MenuHomePhabricator

D12511.id36341.diff
No OneTemporary

D12511.id36341.diff

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

Mime Type
text/plain
Expires
Tue, May 20, 21:59 (18 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866013
Default Alt Text
D12511.id36341.diff (2 KB)

Event Timeline