Skip to content

Commit 53552af

Browse files
committed
[headerssync] Make m_commit_offset protected
1 parent 5b3f05b commit 53552af

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/headerssync.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ static_assert(sizeof(CompressedHeader) == 48);
2424

2525
HeadersSyncState::HeadersSyncState(NodeId id, const Consensus::Params& consensus_params,
2626
const CBlockIndex* chain_start, const arith_uint256& minimum_required_work) :
27+
m_commit_offset(GetRand<unsigned>(HEADER_COMMITMENT_PERIOD)),
2728
m_id(id), m_consensus_params(consensus_params),
2829
m_chain_start(chain_start),
2930
m_minimum_required_work(minimum_required_work),
3031
m_current_chain_work(chain_start->nChainWork),
31-
m_commit_offset(GetRand<unsigned>(HEADER_COMMITMENT_PERIOD)),
3232
m_last_header_received(m_chain_start->GetBlockHeader()),
3333
m_current_height(chain_start->nHeight)
3434
{

src/headerssync.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ class HeadersSyncState {
175175
*/
176176
CBlockLocator NextHeadersRequestLocator() const;
177177

178+
protected:
179+
/** The (secret) offset on the heights for which to create commitments.
180+
*
181+
* m_header_commitments entries are created at any height h for which
182+
* (h % HEADER_COMMITMENT_PERIOD) == m_commit_offset. */
183+
const unsigned m_commit_offset;
184+
178185
private:
179186
/** Clear out all download state that might be in progress (freeing any used
180187
* memory), and mark this object as no longer usable.
@@ -222,12 +229,6 @@ class HeadersSyncState {
222229
/** A queue of commitment bits, created during the 1st phase, and verified during the 2nd. */
223230
bitdeque<> m_header_commitments;
224231

225-
/** The (secret) offset on the heights for which to create commitments.
226-
*
227-
* m_header_commitments entries are created at any height h for which
228-
* (h % HEADER_COMMITMENT_PERIOD) == m_commit_offset. */
229-
const unsigned m_commit_offset;
230-
231232
/** m_max_commitments is a bound we calculate on how long an honest peer's chain could be,
232233
* given the MTP rule.
233234
*

0 commit comments

Comments
 (0)