mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
Move headerssync logging to BCLog::NET
This commit is contained in:
parent
e9035f867a
commit
132ed7eaaa
3 changed files with 12 additions and 16 deletions
|
@ -42,7 +42,7 @@ HeadersSyncState::HeadersSyncState(NodeId id, const Consensus::Params& consensus
|
|||
// could try again, if necessary, to sync a longer chain).
|
||||
m_max_commitments = 6*(Ticks<std::chrono::seconds>(GetAdjustedTime() - NodeSeconds{std::chrono::seconds{chain_start->GetMedianTimePast()}}) + MAX_FUTURE_BLOCK_TIME) / HEADER_COMMITMENT_PERIOD;
|
||||
|
||||
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());
|
||||
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());
|
||||
}
|
||||
|
||||
/** Free any memory in use, and mark this object as no longer usable. This is
|
||||
|
@ -92,7 +92,7 @@ HeadersSyncState::ProcessingResult HeadersSyncState::ProcessNextHeaders(const
|
|||
// If we're in PRESYNC and we get a non-full headers
|
||||
// message, then the peer's chain has ended and definitely doesn't
|
||||
// have enough work, so we can stop our sync.
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: incomplete headers message at height=%i (presync phase)\n", m_id, m_current_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: incomplete headers message at height=%i (presync phase)\n", m_id, m_current_height);
|
||||
}
|
||||
}
|
||||
} else if (m_download_state == State::REDOWNLOAD) {
|
||||
|
@ -118,7 +118,7 @@ HeadersSyncState::ProcessingResult HeadersSyncState::ProcessNextHeaders(const
|
|||
// If we hit our target blockhash, then all remaining headers will be
|
||||
// returned and we can clear any leftover internal state.
|
||||
if (m_redownloaded_headers.empty() && m_process_all_remaining_headers) {
|
||||
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);
|
||||
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);
|
||||
} else if (full_headers_message) {
|
||||
// If the headers message is full, we need to request more.
|
||||
ret.request_more = true;
|
||||
|
@ -127,7 +127,7 @@ HeadersSyncState::ProcessingResult HeadersSyncState::ProcessNextHeaders(const
|
|||
// declining to serve us that full chain again. Give up.
|
||||
// Note that there's no more processing to be done with these
|
||||
// headers, so we can still return success.
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ bool HeadersSyncState::ValidateAndStoreHeadersCommitments(const std::vector<CBlo
|
|||
// This might be benign -- perhaps our peer reorged away from the chain
|
||||
// they were on. Give up on this sync for now (likely we will start a
|
||||
// new sync with a new starting point).
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (presync phase)\n", m_id, m_current_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (presync phase)\n", m_id, m_current_height);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ bool HeadersSyncState::ValidateAndStoreHeadersCommitments(const std::vector<CBlo
|
|||
m_redownload_buffer_last_hash = m_chain_start->GetBlockHash();
|
||||
m_redownload_chain_work = m_chain_start->nChainWork;
|
||||
m_download_state = State::REDOWNLOAD;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ bool HeadersSyncState::ValidateAndProcessSingleHeader(const CBlockHeader& curren
|
|||
// adjustment maximum.
|
||||
if (!PermittedDifficultyTransition(m_consensus_params, next_height,
|
||||
m_last_header_received.nBits, current.nBits)) {
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (presync phase)\n", m_id, next_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (presync phase)\n", m_id, next_height);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ bool HeadersSyncState::ValidateAndProcessSingleHeader(const CBlockHeader& curren
|
|||
// It's possible the chain grew since we started the sync; so
|
||||
// potentially we could succeed in syncing the peer's chain if we
|
||||
// try again later.
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: exceeded max commitments at height=%i (presync phase)\n", m_id, next_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: exceeded max commitments at height=%i (presync phase)\n", m_id, next_height);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
|
|||
// Ensure that we're working on a header that connects to the chain we're
|
||||
// downloading.
|
||||
if (header.hashPrevBlock != m_redownload_buffer_last_hash) {
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (redownload phase)\n", m_id, next_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: non-continuous headers at height=%i (redownload phase)\n", m_id, next_height);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
|
|||
|
||||
if (!PermittedDifficultyTransition(m_consensus_params, next_height,
|
||||
previous_nBits, header.nBits)) {
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (redownload phase)\n", m_id, next_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: invalid difficulty transition at height=%i (redownload phase)\n", m_id, next_height);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
|
|||
// target blockhash just because we ran out of commitments.
|
||||
if (!m_process_all_remaining_headers && next_height % HEADER_COMMITMENT_PERIOD == m_commit_offset) {
|
||||
if (m_header_commitments.size() == 0) {
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: commitment overrun at height=%i (redownload phase)\n", m_id, next_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: commitment overrun at height=%i (redownload phase)\n", m_id, next_height);
|
||||
// Somehow our peer managed to feed us a different chain and
|
||||
// we've run out of commitments.
|
||||
return false;
|
||||
|
@ -264,7 +264,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
|
|||
bool expected_commitment = m_header_commitments.front();
|
||||
m_header_commitments.pop_front();
|
||||
if (commitment != expected_commitment) {
|
||||
LogPrint(BCLog::HEADERSSYNC, "Initial headers sync aborted with peer=%d: commitment mismatch at height=%i (redownload phase)\n", m_id, next_height);
|
||||
LogPrint(BCLog::NET, "Initial headers sync aborted with peer=%d: commitment mismatch at height=%i (redownload phase)\n", m_id, next_height);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,6 @@ const CLogCategoryDesc LogCategories[] =
|
|||
#endif
|
||||
{BCLog::UTIL, "util"},
|
||||
{BCLog::BLOCKSTORE, "blockstorage"},
|
||||
{BCLog::HEADERSSYNC, "headerssync"},
|
||||
{BCLog::ALL, "1"},
|
||||
{BCLog::ALL, "all"},
|
||||
};
|
||||
|
@ -264,8 +263,6 @@ std::string LogCategoryToStr(BCLog::LogFlags category)
|
|||
return "util";
|
||||
case BCLog::LogFlags::BLOCKSTORE:
|
||||
return "blockstorage";
|
||||
case BCLog::LogFlags::HEADERSSYNC:
|
||||
return "headerssync";
|
||||
case BCLog::LogFlags::ALL:
|
||||
return "all";
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@ namespace BCLog {
|
|||
#endif
|
||||
UTIL = (1 << 25),
|
||||
BLOCKSTORE = (1 << 26),
|
||||
HEADERSSYNC = (1 << 27),
|
||||
ALL = ~(uint32_t)0,
|
||||
};
|
||||
enum class Level {
|
||||
|
|
Loading…
Add table
Reference in a new issue