From 53552affca381cdb5103ecdbcc7f3fb562e66ac4 Mon Sep 17 00:00:00 2001 From: dergoegge Date: Mon, 12 Dec 2022 21:05:33 +0000 Subject: [PATCH] [headerssync] Make m_commit_offset protected --- src/headerssync.cpp | 2 +- src/headerssync.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/headerssync.cpp b/src/headerssync.cpp index 757b942cd9..a3adfb4f70 100644 --- a/src/headerssync.cpp +++ b/src/headerssync.cpp @@ -24,11 +24,11 @@ static_assert(sizeof(CompressedHeader) == 48); HeadersSyncState::HeadersSyncState(NodeId id, const Consensus::Params& consensus_params, const CBlockIndex* chain_start, const arith_uint256& minimum_required_work) : + m_commit_offset(GetRand(HEADER_COMMITMENT_PERIOD)), m_id(id), m_consensus_params(consensus_params), m_chain_start(chain_start), m_minimum_required_work(minimum_required_work), m_current_chain_work(chain_start->nChainWork), - m_commit_offset(GetRand(HEADER_COMMITMENT_PERIOD)), m_last_header_received(m_chain_start->GetBlockHeader()), m_current_height(chain_start->nHeight) { diff --git a/src/headerssync.h b/src/headerssync.h index 16da964246..e93f67e6da 100644 --- a/src/headerssync.h +++ b/src/headerssync.h @@ -175,6 +175,13 @@ public: */ CBlockLocator NextHeadersRequestLocator() const; +protected: + /** The (secret) offset on the heights for which to create commitments. + * + * m_header_commitments entries are created at any height h for which + * (h % HEADER_COMMITMENT_PERIOD) == m_commit_offset. */ + const unsigned m_commit_offset; + private: /** Clear out all download state that might be in progress (freeing any used * memory), and mark this object as no longer usable. @@ -222,12 +229,6 @@ private: /** A queue of commitment bits, created during the 1st phase, and verified during the 2nd. */ bitdeque<> m_header_commitments; - /** The (secret) offset on the heights for which to create commitments. - * - * m_header_commitments entries are created at any height h for which - * (h % HEADER_COMMITMENT_PERIOD) == m_commit_offset. */ - const unsigned m_commit_offset; - /** m_max_commitments is a bound we calculate on how long an honest peer's chain could be, * given the MTP rule. *