20 m_commit_offset((
assert(params.commitment_period > 0),
22 m_id(id), m_consensus_params(consensus_params),
24 m_chain_start(chain_start),
25 m_minimum_required_work(minimum_required_work),
26 m_current_chain_work(chain_start->nChainWork),
27 m_last_header_received(m_chain_start->GetBlockHeader()),
28 m_current_height(chain_start->
nHeight)
66 std::span<const CBlockHeader> received_headers,
const bool full_headers_message)
70 Assume(!received_headers.empty());
71 if (received_headers.empty())
return ret;
86 ret.request_more =
true;
101 for (
const auto& hdr : received_headers) {
119 }
else if (full_headers_message) {
121 ret.request_more =
true;
139 Assume(headers.size() > 0);
140 if (headers.size() == 0)
return true;
156 for (
const auto& hdr : headers) {
188 LogDebug(
BCLog::NET,
"Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (presync phase)\n",
m_id, next_height);
200 LogDebug(
BCLog::NET,
"Initial headers sync aborted with peer=%d: exceeded max commitments at height=%i (presync phase)\n",
m_id, next_height);
222 LogDebug(
BCLog::NET,
"Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (redownload phase)\n",
m_id, next_height);
227 uint32_t previous_nBits{0};
235 previous_nBits, header.
nBits)) {
236 LogDebug(
BCLog::NET,
"Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (redownload phase)\n",
m_id, next_height);
255 LogDebug(
BCLog::NET,
"Initial headers sync aborted with peer=%d: commitment overrun at height=%i (redownload phase)\n",
m_id, next_height);
263 if (commitment != expected_commitment) {
264 LogDebug(
BCLog::NET,
"Initial headers sync aborted with peer=%d: commitment mismatch at height=%i (redownload phase)\n",
m_id, next_height);
279 std::vector<CBlockHeader>
ret;
299 std::vector<uint256> locator;
311 locator.insert(locator.end(), chain_start_locator.begin(), chain_start_locator.end());
arith_uint256 GetBlockProof(const CBlockIndex &block)
std::vector< uint256 > 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 time before the block ...
#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 ...
uint256 GetBlockHash() const
int64_t GetMedianTimePast() 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 LogDebug(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...
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.
static time_point now() noexcept
Return current system time or mocked time, if set.
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
void ClearShrink(V &v) noexcept
Clear a vector (or std::deque) and release its allocated memory.