115 const size_t count,
uint256 prev_hash,
const int32_t nVersion,
116 uint32_t prev_time,
const uint256& merkle_root,
const uint32_t nBits)
118 std::vector<CBlockHeader> headers(
count);
119 for (
auto& next_header : headers) {
120 next_header.nVersion = nVersion;
121 next_header.hashPrevBlock = prev_hash;
122 next_header.hashMerkleRoot = merkle_root;
123 next_header.nTime = ++prev_time;
124 next_header.nBits = nBits;
127 prev_hash = next_header.GetHash();
146 const auto& first_chain{FirstChain()};
147 const auto& second_chain{SecondChain()};
159 first_chain.front().GetHash());
163 CHECK_RESULT(hss.ProcessNextHeaders(std::span{first_chain}.subspan(1),
true),
164 hss, State::REDOWNLOAD,
175 CHECK_RESULT(hss.ProcessNextHeaders(second_chain,
true),
185 const auto& first_chain{FirstChain()};
188 for (
const bool full_headers_message : {
false,
true}) {
193 const auto genesis_hash{genesis.GetHash()};
195 hss, State::REDOWNLOAD,
203 hss, State::REDOWNLOAD,
210 hss, State::REDOWNLOAD,
217 CHECK_RESULT(hss.ProcessNextHeaders({first_chain.begin() + REDOWNLOAD_BUFFER_SIZE + 1, first_chain.end()}, full_headers_message),
221 first_chain.size() - 1, first_chain.front().GetHash(),
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
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.