27 std::vector<CBlockIndex> blocks;
28 const uint32_t fixed_time = fuzzed_data_provider.
ConsumeIntegral<uint32_t>();
29 const uint32_t fixed_bits = fuzzed_data_provider.
ConsumeIntegral<uint32_t>();
31 const std::optional<CBlockHeader> block_header = ConsumeDeserializable<CBlockHeader>(fuzzed_data_provider);
37 CBlockIndex* previous_block = blocks.empty() ? nullptr : &
PickValue(fuzzed_data_provider, blocks);
38 const int current_height = (previous_block !=
nullptr && previous_block->
nHeight != std::numeric_limits<int>::max()) ? previous_block->
nHeight + 1 : 0;
40 current_block.pprev = previous_block;
43 current_block.
nHeight = current_height;
48 current_block.nTime = fixed_time + seconds;
52 current_block.nBits = fixed_bits;
59 blocks.push_back(current_block);
64 if (current_block.nHeight != std::numeric_limits<int>::max() && current_block.nHeight - (consensus_params.
DifficultyAdjustmentInterval() - 1) >= 0) {
78 const std::optional<uint256> hash = ConsumeDeserializable<uint256>(fuzzed_data_provider);
arith_uint256 GetBlockProof(const CBlockIndex &block)
int64_t GetBlockProofEquivalentTime(const CBlockIndex &to, const CBlockIndex &from, const CBlockIndex &tip, const Consensus::Params ¶ms)
Return the time it would take to redo the work difference between from and to, assuming the current h...
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
const CChainParams & Params()
Return the currently selected parameters.
static const std::string MAIN
Chain name strings.
The block chain is a tree shaped structure starting with the genesis block at the root,...
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
int nHeight
height of the entry in the chain. The genesis block has height 0
const Consensus::Params & GetConsensus() const
T ConsumeIntegralInRange(T min, T max)
256-bit unsigned big integer.
if(na.IsAddrV1Compatible())
unsigned int GetNextWorkRequired(const CBlockIndex *pindexLast, const CBlockHeader *pblock, const Consensus::Params ¶ms)
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
unsigned int CalculateNextWorkRequired(const CBlockIndex *pindexLast, int64_t nFirstBlockTime, const Consensus::Params ¶ms)
Parameters that influence chain consensus.
int64_t DifficultyAdjustmentInterval() const
int64_t nPowTargetSpacing
FUZZ_TARGET_INIT(pow, initialize_pow)
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
arith_uint256 ConsumeArithUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
bool AdditionOverflow(const T i, const T j) noexcept