59 .cache_bytes = 1 << 20,
64 int files_count = fuzzed_data_provider.ConsumeIntegralInRange(1, 100);
65 std::vector<std::unique_ptr<CBlockFileInfo>> files;
66 files.reserve(files_count);
67 std::vector<std::pair<int, const CBlockFileInfo*>> files_info;
68 files_info.reserve(files_count);
69 for (
int i = 0; i < files_count; i++) {
71 files.push_back(std::make_unique<CBlockFileInfo>(std::move(*file_info)));
72 files_info.emplace_back(i, files.back().get());
79 int blocks_count = fuzzed_data_provider.ConsumeIntegralInRange(files_count * 10, files_count * 100);
80 std::vector<std::unique_ptr<CBlockIndex>> blocks;
81 blocks.reserve(blocks_count);
82 std::vector<const CBlockIndex*> blocks_info;
83 blocks_info.reserve(blocks_count);
84 for (
int i = 0; i < blocks_count; i++) {
85 CBlockHeader header{ConsumeBlockHeader(fuzzed_data_provider)};
86 blocks.push_back(std::make_unique<CBlockIndex>(std::move(header)));
87 blocks.back()->phashBlock = &g_block_hash;
88 blocks_info.push_back(blocks.back().get());
92 assert(block_index.WriteBatchSync(files_info, files_count - 1, blocks_info));
97 for (
const auto& [n, file_info]: files_info) {
98 assert(block_index.ReadBlockFileInfo(n, info));
99 assert(info == *file_info);
104 assert(block_index.ReadLastBlockFile(last_block_file));
105 assert(last_block_file == files_count - 1);
109 block_index.WriteReindexing(
true);
110 block_index.ReadReindexing(reindexing);
112 block_index.WriteReindexing(
false);
113 block_index.ReadReindexing(reindexing);
117 const std::string flag_name = fuzzed_data_provider.ConsumeRandomLengthString(100);
119 block_index.WriteFlag(flag_name,
true);
120 block_index.ReadFlag(flag_name, flag_value);
122 block_index.WriteFlag(flag_name,
false);
123 block_index.ReadFlag(flag_name, flag_value);
129 const auto inserter = [&](
const uint256&) {
130 return blocks.back().get();
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.