Skip to content

Commit

Permalink
validation: Use span for ImportBlocks paths
Browse files Browse the repository at this point in the history
Makes it friendlier for potential future users of the kernel library if
they do not store the headers in a std::vector, but can guarantee
contiguous memory.
  • Loading branch information
TheCharlatan committed Aug 30, 2024
1 parent 20515ea commit a2955f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/node/blockstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ class ImportingNow
}
};

void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFiles)
void ImportBlocks(ChainstateManager& chainman, std::span<const fs::path> import_paths)
{
ImportingNow imp{chainman.m_blockman.m_importing};

Expand Down Expand Up @@ -1245,7 +1245,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
}

// -loadblock=
for (const fs::path& path : vImportFiles) {
for (const fs::path& path : import_paths) {
AutoFile file{fsbridge::fopen(path, "rb")};
if (!file.IsNull()) {
LogPrintf("Importing blocks file %s...\n", fs::PathToString(path));
Expand Down
3 changes: 2 additions & 1 deletion src/node/blockstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <memory>
#include <optional>
#include <set>
#include <span>
#include <string>
#include <unordered_map>
#include <utility>
Expand Down Expand Up @@ -429,7 +430,7 @@ class BlockManager
void CleanupBlockRevFiles() const;
};

void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFiles);
void ImportBlocks(ChainstateManager& chainman, std::span<const fs::path> import_paths);
} // namespace node

#endif // BITCOIN_NODE_BLOCKSTORAGE_H

0 comments on commit a2955f0

Please sign in to comment.