32 : m_id(id), m_consensus_params(consensus_params),
33 m_chain_start(chain_start),
34 m_minimum_required_work(minimum_required_work),
35 m_current_chain_work(chain_start->nChainWork),
37 m_last_header_received(m_chain_start->GetBlockHeader()),
38 m_current_height(chain_start->
nHeight) {
56 "Initial headers sync started with peer=%d: height=%i, "
57 "max_commitments=%i, min_work=%s\n",
86 const std::vector<CBlockHeader> &received_headers,
87 const bool full_headers_message) {
90 Assume(!received_headers.empty());
91 if (received_headers.empty()) {
118 "Initial headers sync aborted with peer=%d: incomplete "
119 "headers message at height=%i (presync phase)\n",
129 for (
const auto &hdr : received_headers) {
148 "Initial headers sync complete with peer=%d: "
149 "releasing all at height=%i (redownload phase)\n",
151 }
else if (full_headers_message) {
161 "Initial headers sync aborted with peer=%d: incomplete "
162 "headers message at height=%i (redownload phase)\n",
175 const std::vector<CBlockHeader> &headers) {
177 Assume(headers.size() > 0);
178 if (headers.size() == 0) {
193 "Initial headers sync aborted with peer=%d: non-continuous "
194 "headers at height=%i (presync phase)\n",
201 for (
const auto &hdr : headers) {
215 "Initial headers sync transition with peer=%d: reached "
216 "sufficient work at height=%i, redownloading from height=%i\n",
239 LogPrintf(
"Initial headers sync aborted with peer=%d: invalid "
240 "difficulty transition at height=%i (presync phase)\n",
253 LogPrintf(
"Initial headers sync aborted with peer=%d: exceeded max "
254 "commitments at height=%i (presync phase)\n",
280 "Initial headers sync aborted with peer=%d: non-continuous "
281 "headers at height=%i (redownload phase)\n",
287 uint32_t previous_nBits{0};
295 previous_nBits, header.
nBits)) {
297 "Initial headers sync aborted with peer=%d: invalid "
298 "difficulty transition at height=%i (redownload phase)\n",
320 "Initial headers sync aborted with peer=%d: commitment "
321 "overrun at height=%i (redownload phase)\n",
330 if (commitment != expected_commitment) {
332 "Initial headers sync aborted with peer=%d: commitment "
333 "mismatch at height=%i (redownload phase)\n",
348 std::vector<CBlockHeader> ret;
373 std::vector<BlockHash> locator;
387 locator.insert(locator.end(), chain_start_locator.begin(),
388 chain_start_locator.end());
arith_uint256 GetBlockProof(const CBlockIndex &block)
std::vector< BlockHash > LocatorEntries(const CBlockIndex *index)
Construct a list of hash entries to put in a locator.
static constexpr int64_t MAX_FUTURE_BLOCK_TIME
Maximum amount of time that a block timestamp is allowed to exceed the current network-adjusted time ...
#define Assume(val)
Assume is the identity function.
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 ...
int64_t GetMedianTimePast() const
BlockHash GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
256-bit unsigned big integer.
std::string ToString() const
size_type size() const noexcept
Count the number of bits in the container.
#define LogPrint(category,...)
bool PermittedDifficultyTransition(const Consensus::Params ¶ms, int64_t height, uint32_t old_nbits, uint32_t new_nbits)
Return false if the proof-of-work requirement specified by new_nbits at a given height is not possibl...
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Parameters that influence chain consensus.
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
NodeClock::time_point GetAdjustedTime()
void ClearShrink(V &v) noexcept
Clear a vector (or std::deque) and release its allocated memory.