6#include <chainparams.h>
13#include <validation.h>
51 static const auto testing_setup = MakeNoLogFileContext<>(
ChainType::MAIN);
52 g_setup = testing_setup.get();
61 .cache_bytes = 1 << 20,
67 std::vector<std::unique_ptr<CBlockFileInfo>> files;
68 files.reserve(files_count);
69 std::vector<std::pair<int, const CBlockFileInfo*>> files_info;
70 files_info.reserve(files_count);
71 for (
int i = 0; i < files_count; i++) {
73 files.push_back(std::make_unique<CBlockFileInfo>(std::move(*file_info)));
74 files_info.emplace_back(i, files.back().get());
82 std::vector<std::unique_ptr<CBlockIndex>> blocks;
83 blocks.reserve(blocks_count);
84 std::vector<const CBlockIndex*> blocks_info;
85 blocks_info.reserve(blocks_count);
86 for (
int i = 0; i < blocks_count; i++) {
88 blocks.push_back(std::make_unique<CBlockIndex>(std::move(header)));
89 blocks.back()->phashBlock = &g_block_hash;
90 blocks_info.push_back(blocks.back().get());
94 block_index.WriteBatchSync(files_info, files_count - 1, blocks_info);
99 for (
const auto& [n, file_info]: files_info) {
100 assert(block_index.ReadBlockFileInfo(n, info));
101 assert(info == *file_info);
106 assert(block_index.ReadLastBlockFile(last_block_file));
107 assert(last_block_file == files_count - 1);
111 block_index.WriteReindexing(
true);
112 block_index.ReadReindexing(reindexing);
114 block_index.WriteReindexing(
false);
115 block_index.ReadReindexing(reindexing);
121 block_index.WriteFlag(flag_name,
true);
122 block_index.ReadFlag(flag_name, flag_value);
124 block_index.WriteFlag(flag_name,
false);
125 block_index.ReadFlag(flag_name, flag_value);
131 const auto inserter = [&](
const uint256&) {
132 return blocks.back().get();
FUZZ_TARGET(block_index,.init=init_block_index)
const CChainParams & Params()
Return the currently selected parameters.
const CBlock & GenesisBlock() const
const Consensus::Params & GetConsensus() const
std::string ConsumeRandomLengthString(size_t max_length)
T ConsumeIntegralInRange(T min, T max)
Access to the block database (blocks/index/)
uint32_t nSize
number of used bytes of block file
uint32_t nUndoSize
number of used bytes in the undo file
uint64_t nTimeFirst
earliest time of block in file
uint64_t nTimeLast
latest time of block in file
uint32_t nHeightFirst
lowest height of block in file
uint32_t nBlocks
number of blocks stored in file
uint32_t nHeightLast
highest height of block in file
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
bool operator==(const CNetAddr &a, const CNetAddr &b)
util::SignalInterrupt m_interrupt
Application-specific storage settings.
fs::path path
Location in the filesystem where leveldb data will be stored.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
FuzzedDataProvider & fuzzed_data_provider