mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
validation: Extract basic block file logic into FlatFileSeq class.
This commit is contained in:
parent
62e7addb63
commit
9183d6ef65
6 changed files with 80 additions and 6 deletions
23
src/flatfile.cpp
Normal file
23
src/flatfile.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2019 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <flatfile.h>
|
||||
#include <tinyformat.h>
|
||||
|
||||
FlatFileSeq::FlatFileSeq(fs::path dir, const char* prefix, size_t chunk_size) :
|
||||
m_dir(std::move(dir)),
|
||||
m_prefix(prefix),
|
||||
m_chunk_size(chunk_size)
|
||||
{
|
||||
if (chunk_size == 0) {
|
||||
throw std::invalid_argument("chunk_size must be positive");
|
||||
}
|
||||
}
|
||||
|
||||
fs::path FlatFileSeq::FileName(const CDiskBlockPos& pos) const
|
||||
{
|
||||
return m_dir / strprintf("%s%05u.dat", m_prefix, pos.nFile);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue