Skip to content

Commit 853c4ed

Browse files
committed
[net] Remove asmap argument from CNode::CopyStats()
This saves passing around a reference to the asmap std::vector<bool>.
1 parent 9fd5618 commit 853c4ed

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,13 @@ Network CNode::ConnectedThroughNetwork() const
552552

553553
#undef X
554554
#define X(name) stats.name = name
555-
void CNode::CopyStats(CNodeStats& stats, const std::vector<bool>& asmap)
555+
void CNode::CopyStats(CNodeStats& stats)
556556
{
557557
stats.nodeid = this->GetId();
558558
X(nServices);
559559
X(addr);
560560
X(addrBind);
561561
stats.m_network = ConnectedThroughNetwork();
562-
stats.m_mapped_as = addr.GetMappedAS(asmap);
563562
if (m_tx_relay != nullptr) {
564563
LOCK(m_tx_relay->cs_filter);
565564
stats.fRelayTxes = m_tx_relay->fRelayTxes;
@@ -2804,7 +2803,8 @@ void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats) const
28042803
vstats.reserve(vNodes.size());
28052804
for (CNode* pnode : vNodes) {
28062805
vstats.emplace_back();
2807-
pnode->CopyStats(vstats.back(), addrman.GetAsmap());
2806+
pnode->CopyStats(vstats.back());
2807+
vstats.back().m_mapped_as = pnode->addr.GetMappedAS(addrman.GetAsmap());
28082808
}
28092809
}
28102810

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ class CNode
652652

653653
void CloseSocketDisconnect();
654654

655-
void CopyStats(CNodeStats& stats, const std::vector<bool>& asmap);
655+
void CopyStats(CNodeStats& stats);
656656

657657
ServiceFlags GetLocalServices() const
658658
{

src/test/fuzz/net.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ FUZZ_TARGET_INIT(net, initialize_net)
3939
node.CloseSocketDisconnect();
4040
},
4141
[&] {
42-
const std::vector<bool> asmap = ConsumeRandomLengthBitVector(fuzzed_data_provider);
43-
if (!SanityCheckASMap(asmap, 128)) {
44-
return;
45-
}
4642
CNodeStats stats;
47-
node.CopyStats(stats, asmap);
43+
node.CopyStats(stats);
4844
},
4945
[&] {
5046
const CNode* add_ref_node = node.AddRef();

0 commit comments

Comments
 (0)