diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-01-05 15:06:56 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-01-05 15:08:06 +0100 |
commit | fa467f3913918701c765f9bc754203b4591b894f (patch) | |
tree | 18cabb6f5817b62a07e72bbd201aa778a24284b8 /src/node/blockstorage.cpp | |
parent | fa88cfd3f9896d5b56ea6c111a23f90a79253c18 (diff) |
move-only: Create WriteBlockIndexDB helper
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
Diffstat (limited to 'src/node/blockstorage.cpp')
-rw-r--r-- | src/node/blockstorage.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index ad2bb3d3e8..3cc53e27e2 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -350,6 +350,26 @@ void BlockManager::Unload() m_block_index.clear(); } +bool BlockManager::WriteBlockIndexDB() +{ + std::vector<std::pair<int, const CBlockFileInfo*>> vFiles; + vFiles.reserve(setDirtyFileInfo.size()); + for (std::set<int>::iterator it = setDirtyFileInfo.begin(); it != setDirtyFileInfo.end();) { + vFiles.push_back(std::make_pair(*it, &vinfoBlockFile[*it])); + setDirtyFileInfo.erase(it++); + } + std::vector<const CBlockIndex*> vBlocks; + vBlocks.reserve(setDirtyBlockIndex.size()); + for (std::set<CBlockIndex*>::iterator it = setDirtyBlockIndex.begin(); it != setDirtyBlockIndex.end();) { + vBlocks.push_back(*it); + setDirtyBlockIndex.erase(it++); + } + if (!m_block_tree_db->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) { + return false; + } + return true; +} + bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman) { if (!LoadBlockIndex(::Params().GetConsensus(), chainman)) { |