7#include <chainparams.h>
15#include <validation.h>
22 static const auto testing_setup = MakeNoLogFileContext<>(
28 const std::vector<CBlockHeader>& all_headers,
29 std::vector<CBlockHeader>& new_headers)
31 Assume(!new_headers.empty());
34 all_headers.empty() ? &genesis_header : &all_headers.back()};
36 for (
auto& header : new_headers) {
39 prev_header = &header;
65 const uint256 genesis_hash = genesis_header.GetHash();
75 std::vector<CBlockHeader> all_headers;
76 std::vector<CBlockHeader>::const_iterator redownloaded_it;
78 bool requested_more{
true};
80 while (requested_more) {
81 std::vector<CBlockHeader> headers;
85 if (presync || fuzzed_data_provider.
ConsumeBool()) {
86 auto deser_headers = ConsumeDeserializable<std::vector<CBlockHeader>>(fuzzed_data_provider);
87 if (!deser_headers || deser_headers->empty())
return;
93 headers.swap(*deser_headers);
94 }
else if (
auto num_headers_left{std::distance(redownloaded_it, all_headers.cend())}; num_headers_left > 0) {
97 auto begin_it{redownloaded_it};
99 headers.insert(headers.cend(), begin_it, redownloaded_it);
102 if (headers.empty())
return;
106 if (result.request_more) {
108 all_headers.insert(all_headers.cend(), headers.cbegin(), headers.cend());
112 redownloaded_it = all_headers.cbegin();
arith_uint256 UintToArith256(const uint256 &a)
const CChainParams & Params()
Return the currently selected parameters.
#define Assume(val)
Assume is the identity function.
The block chain is a tree shaped structure starting with the genesis block at the root,...
int64_t GetMedianTimePast() const
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
const CBlock & GenesisBlock() const
T ConsumeIntegralInRange(T min, T max)
256-bit unsigned big integer.
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
arith_uint256 CalculateClaimedHeadersWork(std::span< const CBlockHeader > headers)
Return the sum of the claimed work on a given set of headers.