Skip to content

Commit 132ed7e

Browse files
committed
Move headerssync logging to BCLog::NET
1 parent e9035f8 commit 132ed7e

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

src/headerssync.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ HeadersSyncState::HeadersSyncState(NodeId id, const Consensus::Params& consensus
4242
// could try again, if necessary, to sync a longer chain).
4343
m_max_commitments = 6*(Ticks<std::chrono::seconds>(GetAdjustedTime() - NodeSeconds{std::chrono::seconds{chain_start->GetMedianTimePast()}}) + MAX_FUTURE_BLOCK_TIME) / HEADER_COMMITMENT_PERIOD;
4444

45-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync started with peer=%d: height=%i, max_commitments=%i, min_work=%s\n", m_id, m_current_height, m_max_commitments, m_minimum_required_work.ToString());
45+
LogPrint(BCLog::NET, "Initial headers sync started with peer=%d: height=%i, max_commitments=%i, min_work=%s\n", m_id, m_current_height, m_max_commitments, m_minimum_required_work.ToString());
4646
}
4747

4848
/** Free any memory in use, and mark this object as no longer usable. This is
@@ -92,7 +92,7 @@ HeadersSyncState::ProcessingResult HeadersSyncState::ProcessNextHeaders(const
9292
// If we're in PRESYNC and we get a non-full headers
9393
// message, then the peer's chain has ended and definitely doesn't
9494
// have enough work, so we can stop our sync.
95-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: incomplete headers message at height=%i (presync phase)\n", m_id, m_current_height);
95+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: incomplete headers message at height=%i (presync phase)\n", m_id, m_current_height);
9696
}
9797
}
9898
} else if (m_download_state == State::REDOWNLOAD) {
@@ -118,7 +118,7 @@ HeadersSyncState::ProcessingResult HeadersSyncState::ProcessNextHeaders(const
118118
// If we hit our target blockhash, then all remaining headers will be
119119
// returned and we can clear any leftover internal state.
120120
if (m_redownloaded_headers.empty() && m_process_all_remaining_headers) {
121-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync complete with peer=%d: releasing all at height=%i (redownload phase)\n", m_id, m_redownload_buffer_last_height);
121+
LogPrint(BCLog::NET, "Initial headers sync complete with peer=%d: releasing all at height=%i (redownload phase)\n", m_id, m_redownload_buffer_last_height);
122122
} else if (full_headers_message) {
123123
// If the headers message is full, we need to request more.
124124
ret.request_more = true;
@@ -127,7 +127,7 @@ HeadersSyncState::ProcessingResult HeadersSyncState::ProcessNextHeaders(const
127127
// declining to serve us that full chain again. Give up.
128128
// Note that there's no more processing to be done with these
129129
// headers, so we can still return success.
130-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: incomplete headers message at height=%i (redownload phase)\n", m_id, m_redownload_buffer_last_height);
130+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: incomplete headers message at height=%i (redownload phase)\n", m_id, m_redownload_buffer_last_height);
131131
}
132132
}
133133
}
@@ -150,7 +150,7 @@ bool HeadersSyncState::ValidateAndStoreHeadersCommitments(const std::vector<CBlo
150150
// This might be benign -- perhaps our peer reorged away from the chain
151151
// they were on. Give up on this sync for now (likely we will start a
152152
// new sync with a new starting point).
153-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (presync phase)\n", m_id, m_current_height);
153+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (presync phase)\n", m_id, m_current_height);
154154
return false;
155155
}
156156

@@ -169,7 +169,7 @@ bool HeadersSyncState::ValidateAndStoreHeadersCommitments(const std::vector<CBlo
169169
m_redownload_buffer_last_hash = m_chain_start->GetBlockHash();
170170
m_redownload_chain_work = m_chain_start->nChainWork;
171171
m_download_state = State::REDOWNLOAD;
172-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync transition with peer=%d: reached sufficient work at height=%i, redownloading from height=%i\n", m_id, m_current_height, m_redownload_buffer_last_height);
172+
LogPrint(BCLog::NET, "Initial headers sync transition with peer=%d: reached sufficient work at height=%i, redownloading from height=%i\n", m_id, m_current_height, m_redownload_buffer_last_height);
173173
}
174174
return true;
175175
}
@@ -188,7 +188,7 @@ bool HeadersSyncState::ValidateAndProcessSingleHeader(const CBlockHeader& curren
188188
// adjustment maximum.
189189
if (!PermittedDifficultyTransition(m_consensus_params, next_height,
190190
m_last_header_received.nBits, current.nBits)) {
191-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (presync phase)\n", m_id, next_height);
191+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (presync phase)\n", m_id, next_height);
192192
return false;
193193
}
194194

@@ -200,7 +200,7 @@ bool HeadersSyncState::ValidateAndProcessSingleHeader(const CBlockHeader& curren
200200
// It's possible the chain grew since we started the sync; so
201201
// potentially we could succeed in syncing the peer's chain if we
202202
// try again later.
203-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: exceeded max commitments at height=%i (presync phase)\n", m_id, next_height);
203+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: exceeded max commitments at height=%i (presync phase)\n", m_id, next_height);
204204
return false;
205205
}
206206
}
@@ -222,7 +222,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
222222
// Ensure that we're working on a header that connects to the chain we're
223223
// downloading.
224224
if (header.hashPrevBlock != m_redownload_buffer_last_hash) {
225-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (redownload phase)\n", m_id, next_height);
225+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (redownload phase)\n", m_id, next_height);
226226
return false;
227227
}
228228

@@ -236,7 +236,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
236236

237237
if (!PermittedDifficultyTransition(m_consensus_params, next_height,
238238
previous_nBits, header.nBits)) {
239-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (redownload phase)\n", m_id, next_height);
239+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (redownload phase)\n", m_id, next_height);
240240
return false;
241241
}
242242

@@ -255,7 +255,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
255255
// target blockhash just because we ran out of commitments.
256256
if (!m_process_all_remaining_headers && next_height % HEADER_COMMITMENT_PERIOD == m_commit_offset) {
257257
if (m_header_commitments.size() == 0) {
258-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: commitment overrun at height=%i (redownload phase)\n", m_id, next_height);
258+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: commitment overrun at height=%i (redownload phase)\n", m_id, next_height);
259259
// Somehow our peer managed to feed us a different chain and
260260
// we've run out of commitments.
261261
return false;
@@ -264,7 +264,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
264264
bool expected_commitment = m_header_commitments.front();
265265
m_header_commitments.pop_front();
266266
if (commitment != expected_commitment) {
267-
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: commitment mismatch at height=%i (redownload phase)\n", m_id, next_height);
267+
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: commitment mismatch at height=%i (redownload phase)\n", m_id, next_height);
268268
return false;
269269
}
270270
}

src/logging.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ const CLogCategoryDesc LogCategories[] =
165165
#endif
166166
{BCLog::UTIL, "util"},
167167
{BCLog::BLOCKSTORE, "blockstorage"},
168-
{BCLog::HEADERSSYNC, "headerssync"},
169168
{BCLog::ALL, "1"},
170169
{BCLog::ALL, "all"},
171170
};
@@ -264,8 +263,6 @@ std::string LogCategoryToStr(BCLog::LogFlags category)
264263
return "util";
265264
case BCLog::LogFlags::BLOCKSTORE:
266265
return "blockstorage";
267-
case BCLog::LogFlags::HEADERSSYNC:
268-
return "headerssync";
269266
case BCLog::LogFlags::ALL:
270267
return "all";
271268
}

src/logging.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ namespace BCLog {
6565
#endif
6666
UTIL = (1 << 25),
6767
BLOCKSTORE = (1 << 26),
68-
HEADERSSYNC = (1 << 27),
6968
ALL = ~(uint32_t)0,
7069
};
7170
enum class Level {

0 commit comments

Comments
 (0)