mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-12 10:30:08 +01:00
Log which peer sent us a header
This also supports -logips.
This commit is contained in:
parent
c04357ff27
commit
d47ed74bd3
1 changed files with 7 additions and 5 deletions
|
@ -1042,7 +1042,7 @@ private:
|
|||
void AddAddressKnown(Peer& peer, const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
|
||||
void PushAddress(Peer& peer, const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
|
||||
|
||||
void LogBlockHeader(const CBlockIndex& index);
|
||||
void LogBlockHeader(const CBlockIndex& index, const CNode& peer);
|
||||
};
|
||||
|
||||
const CNodeState* PeerManagerImpl::State(NodeId pnode) const
|
||||
|
@ -2952,7 +2952,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
|
|||
assert(pindexLast);
|
||||
|
||||
if (processed && received_new_header) {
|
||||
LogBlockHeader(*pindexLast);
|
||||
LogBlockHeader(*pindexLast, pfrom);
|
||||
}
|
||||
|
||||
// Consider fetching more headers if we are not using our headers-sync mechanism.
|
||||
|
@ -3380,7 +3380,7 @@ void PeerManagerImpl::ProcessCompactBlockTxns(CNode& pfrom, Peer& peer, const Bl
|
|||
return;
|
||||
}
|
||||
|
||||
void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index) {
|
||||
void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index, const CNode& peer) {
|
||||
// To prevent log spam, this function should only be called after it was determined that a
|
||||
// header is both new and valid.
|
||||
//
|
||||
|
@ -3392,9 +3392,11 @@ void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index) {
|
|||
// Having this log by default when not in IBD ensures broad availability of
|
||||
// this data in case investigation is merited.
|
||||
const auto msg = strprintf(
|
||||
"Saw new header hash=%s height=%d",
|
||||
"Saw new header hash=%s height=%d peer=%d%s",
|
||||
index.GetBlockHash().ToString(),
|
||||
index.nHeight
|
||||
index.nHeight,
|
||||
peer.GetId(),
|
||||
fLogIPs ? strprintf(" peeraddr=%s", peer.addr.ToStringAddrPort()) : ""
|
||||
);
|
||||
if (m_chainman.IsInitialBlockDownload()) {
|
||||
LogDebug(BCLog::VALIDATION, "%s\n", msg);
|
||||
|
|
Loading…
Add table
Reference in a new issue