Bitcoin ABC  0.22.13
P2P Digital Currency
blockdb.h
Go to the documentation of this file.
1 // Copyright 2020 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_BLOCKDB_H
6 #define BITCOIN_BLOCKDB_H
7 
8 #include <flatfile.h>
9 
10 namespace Consensus {
11 struct Params;
12 }
13 
14 class CBlock;
15 class CBlockIndex;
16 
18 static constexpr unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
20 static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
21 
24 FILE *OpenUndoFile(const FlatFilePos &pos, bool fReadOnly = false);
25 
29 fs::path GetBlockPosFilename(const FlatFilePos &pos);
30 
34 FILE *OpenBlockFile(const FlatFilePos &pos, bool fReadOnly = false);
35 
37 bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos,
38  const Consensus::Params &params);
39 bool ReadBlockFromDisk(CBlock &block, const CBlockIndex *pindex,
40  const Consensus::Params &params);
41 
42 #endif // BITCOIN_BLOCKDB_H
Definition: block.h:62
FlatFileSeq BlockFileSeq()
Definition: blockdb.cpp:12
FILE * OpenBlockFile(const FlatFilePos &pos, bool fReadOnly=false)
Open a block file (blk?????.dat).
Definition: blockdb.cpp:20
FILE * OpenUndoFile(const FlatFilePos &pos, bool fReadOnly=false)
Open an undo file (rev?????.dat)
Definition: blockdb.cpp:25
static constexpr unsigned int BLOCKFILE_CHUNK_SIZE
The pre-allocation chunk size for blk?????.dat files (since 0.8)
Definition: blockdb.h:18
Parameters that influence chain consensus.
Definition: params.h:59
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &params)
Functions for disk access for blocks.
Definition: blockdb.cpp:33
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: blockindex.h:23
fs::path GetBlockPosFilename(const FlatFilePos &pos)
Translation to a filesystem path.
Definition: blockdb.cpp:29
static const unsigned int UNDOFILE_CHUNK_SIZE
The pre-allocation chunk size for rev?????.dat files (since 0.8)
Definition: blockdb.h:20
FlatFileSeq UndoFileSeq()
Definition: blockdb.cpp:16
FlatFileSeq represents a sequence of numbered files storing raw data.
Definition: flatfile.h:52