log: show placeholders for missing peer fields

Avoid logging an empty field when peer user agent or collision entry is missing.

Co-authored-by: naiyoma <lankas.aurelia@gmail.com>
This commit is contained in:
Lőrinc 2026-01-16 21:51:42 +01:00
parent b65ff0e5a1
commit 9cf82bed32
No known key found for this signature in database
GPG Key ID: 669FFF0FFA477A76
2 changed files with 4 additions and 4 deletions

View File

@ -663,8 +663,8 @@ bool AddrManImpl::Good_(const CService& addr, bool test_before_evict, NodeSecond
}
// Output the entry we'd be colliding with, for debugging purposes
auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]);
LogDebug(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d\n",
colliding_entry != mapInfo.end() ? colliding_entry->second.ToStringAddrPort() : "",
LogDebug(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d",
colliding_entry != mapInfo.end() ? colliding_entry->second.ToStringAddrPort() : "<unknown-addr>",
addr.ToStringAddrPort(),
m_tried_collisions.size());
return false;

View File

@ -3669,8 +3669,8 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
}
const auto mapped_as{m_connman.GetMappedAS(pfrom.addr)};
LogDebug(BCLog::NET, "receive version message: %s: version %d, blocks=%d, us=%s, txrelay=%d, peer=%d%s%s\n",
cleanSubVer, pfrom.nVersion,
LogDebug(BCLog::NET, "receive version message: %s: version %d, blocks=%d, us=%s, txrelay=%d, peer=%d%s%s",
cleanSubVer.empty() ? "<no user agent>" : cleanSubVer, pfrom.nVersion,
peer.m_starting_height, addrMe.ToStringAddrPort(), fRelay, pfrom.GetId(),
pfrom.LogIP(fLogIPs), (mapped_as ? strprintf(", mapped_as=%d", mapped_as) : ""));