diff options
| author | Jim Posen <[email protected]> | 2019-01-06 11:06:31 -0800 |
|---|---|---|
| committer | Jim Posen <[email protected]> | 2019-02-22 17:38:45 -0800 |
| commit | 9183d6ef656c8f3ed406821b99827f9b5f047665 (patch) | |
| tree | 9357c0f274c933b4515af76f1cf62a8a89da9005 /src/flatfile.h | |
| parent | util: Move CheckDiskSpace to util. (diff) | |
| download | discoin-9183d6ef656c8f3ed406821b99827f9b5f047665.tar.xz discoin-9183d6ef656c8f3ed406821b99827f9b5f047665.zip | |
validation: Extract basic block file logic into FlatFileSeq class.
Diffstat (limited to 'src/flatfile.h')
| -rw-r--r-- | src/flatfile.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/flatfile.h b/src/flatfile.h new file mode 100644 index 000000000..9c7131d20 --- /dev/null +++ b/src/flatfile.h @@ -0,0 +1,36 @@ +// 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. + +#ifndef BITCOIN_FLATFILE_H +#define BITCOIN_FLATFILE_H + +#include <chain.h> +#include <fs.h> + +/** + * FlatFileSeq represents a sequence of numbered files storing raw data. This class facilitates + * access to and efficient management of these files. + */ +class FlatFileSeq +{ +private: + const fs::path m_dir; + const char* const m_prefix; + const size_t m_chunk_size; + +public: + /** + * Constructor + * + * @param dir The base directory that all files live in. + * @param prefix A short prefix given to all file names. + * @param chunk_size Disk space is pre-allocated in multiples of this amount. + */ + FlatFileSeq(fs::path dir, const char* prefix, size_t chunk_size); + + /** Get the name of the file at the given position. */ + fs::path FileName(const CDiskBlockPos& pos) const; +}; + +#endif // BITCOIN_FLATFILE_H |