Skip to content

Commit 02a4f1a

Browse files
committed
addrman: log AS only when using asmap
1 parent d53400e commit 02a4f1a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/addrman.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,9 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, std::c
610610
ClearNew(nUBucket, nUBucketPos);
611611
pinfo->nRefCount++;
612612
vvNew[nUBucket][nUBucketPos] = nId;
613-
LogPrint(BCLog::ADDRMAN, "Added %s mapped to AS%i to new[%i][%i]\n",
614-
addr.ToStringAddrPort(), m_netgroupman.GetMappedAS(addr), nUBucket, nUBucketPos);
613+
const auto mapped_as{m_netgroupman.GetMappedAS(addr)};
614+
LogPrint(BCLog::ADDRMAN, "Added %s%s to new[%i][%i]\n",
615+
addr.ToStringAddrPort(), (mapped_as ? strprintf(" mapped to AS%i", mapped_as) : ""), nUBucket, nUBucketPos);
615616
} else {
616617
if (pinfo->nRefCount == 0) {
617618
Delete(nId);
@@ -669,8 +670,9 @@ bool AddrManImpl::Good_(const CService& addr, bool test_before_evict, NodeSecond
669670
} else {
670671
// move nId to the tried tables
671672
MakeTried(info, nId);
672-
LogPrint(BCLog::ADDRMAN, "Moved %s mapped to AS%i to tried[%i][%i]\n",
673-
addr.ToStringAddrPort(), m_netgroupman.GetMappedAS(addr), tried_bucket, tried_bucket_pos);
673+
const auto mapped_as{m_netgroupman.GetMappedAS(addr)};
674+
LogPrint(BCLog::ADDRMAN, "Moved %s%s to tried[%i][%i]\n",
675+
addr.ToStringAddrPort(), (mapped_as ? strprintf(" mapped to AS%i", mapped_as) : ""), tried_bucket, tried_bucket_pos);
674676
return true;
675677
}
676678
}

test/functional/p2p_invalid_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def test_addrv2_unrecognized_network(self):
216216
self.test_addrv2('unrecognized network',
217217
[
218218
'received: addrv2 (25 bytes)',
219-
'9.9.9.9:8333 mapped',
219+
'9.9.9.9:8333',
220220
'Added 1 addresses',
221221
],
222222
bytes.fromhex(

0 commit comments

Comments
 (0)