aboutsummaryrefslogtreecommitdiff
path: root/src/flatfile.cpp
diff options
context:
space:
mode:
authorJim Posen <jim.posen@gmail.com>2019-01-06 11:06:31 -0800
committerJim Posen <jim.posen@gmail.com>2019-02-22 17:38:45 -0800
commit9183d6ef656c8f3ed406821b99827f9b5f047665 (patch)
tree9357c0f274c933b4515af76f1cf62a8a89da9005 /src/flatfile.cpp
parent62e7addb632cad77cbd5fbccbaee51c7b32505d0 (diff)
validation: Extract basic block file logic into FlatFileSeq class.
Diffstat (limited to 'src/flatfile.cpp')
-rw-r--r--src/flatfile.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/flatfile.cpp b/src/flatfile.cpp
new file mode 100644
index 0000000000..c9ca9aa869
--- /dev/null
+++ b/src/flatfile.cpp
@@ -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);
+}