Skip to content

Commit f9fa287

Browse files
committed
Use LogBlockHeader for compact blocks
The only behavior change is that the block height is now added to the log message.
1 parent bad7c91 commit f9fa287

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/net_processing.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ class PeerManagerImpl final : public PeerManager
10721072
void AddAddressKnown(Peer& peer, const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
10731073
void PushAddress(Peer& peer, const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
10741074

1075-
void LogBlockHeader(const CBlockIndex& index, const CNode& peer);
1075+
void LogBlockHeader(const CBlockIndex& index, const CNode& peer, bool via_compact_block);
10761076
};
10771077

10781078
const CNodeState* PeerManagerImpl::State(NodeId pnode) const
@@ -2984,7 +2984,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
29842984
assert(pindexLast);
29852985

29862986
if (processed && received_new_header) {
2987-
LogBlockHeader(*pindexLast, pfrom);
2987+
LogBlockHeader(*pindexLast, pfrom, /*via_compact_block=*/false);
29882988
}
29892989

29902990
// Consider fetching more headers if we are not using our headers-sync mechanism.
@@ -3414,7 +3414,7 @@ void PeerManagerImpl::ProcessCompactBlockTxns(CNode& pfrom, Peer& peer, const Bl
34143414
return;
34153415
}
34163416

3417-
void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index, const CNode& peer) {
3417+
void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index, const CNode& peer, bool via_compact_block) {
34183418
// To prevent log spam, this function should only be called after it was determined that a
34193419
// header is both new and valid.
34203420
//
@@ -3426,7 +3426,8 @@ void PeerManagerImpl::LogBlockHeader(const CBlockIndex& index, const CNode& peer
34263426
// Having this log by default when not in IBD ensures broad availability of
34273427
// this data in case investigation is merited.
34283428
const auto msg = strprintf(
3429-
"Saw new header hash=%s height=%d peer=%d%s",
3429+
"Saw new %sheader hash=%s height=%d peer=%d%s",
3430+
via_compact_block ? "cmpctblock " : "",
34303431
index.GetBlockHash().ToString(),
34313432
index.nHeight,
34323433
peer.GetId(),
@@ -4387,9 +4388,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
43874388
}
43884389
}
43894390

4391+
// If AcceptBlockHeader returned true, it set pindex
4392+
Assert(pindex);
43904393
if (received_new_header) {
4391-
LogInfo("Saw new cmpctblock header hash=%s peer=%d\n",
4392-
blockhash.ToString(), pfrom.GetId());
4394+
LogBlockHeader(*pindex, pfrom, /*via_compact_block=*/true);
43934395
}
43944396

43954397
bool fProcessBLOCKTXN = false;
@@ -4405,8 +4407,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
44054407

44064408
{
44074409
LOCK(cs_main);
4408-
// If AcceptBlockHeader returned true, it set pindex
4409-
assert(pindex);
44104410
UpdateBlockAvailability(pfrom.GetId(), pindex->GetBlockHash());
44114411

44124412
CNodeState *nodestate = State(pfrom.GetId());

0 commit comments

Comments
 (0)