Skip to content

Commit fa82f4e

Browse files
author
MarcoFalke
committed
Remove unused MaybeSetAddrName
This logic is a no-op since it was introduced in commit f9f5cfc. m_addr_name is never initialized to the empty string, because ToStringIPPort never returns an empty string.
1 parent eb09c26 commit fa82f4e

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

src/net.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,10 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
414414
return nullptr;
415415
}
416416
// It is possible that we already have a connection to the IP/port pszDest resolved to.
417-
// In that case, drop the connection that was just created, and return the existing CNode instead.
418-
// Also store the name we used to connect in that CNode, so that future FindNode() calls to that
419-
// name catch this early.
417+
// In that case, drop the connection that was just created.
420418
LOCK(cs_vNodes);
421419
CNode* pnode = FindNode(static_cast<CService>(addrConnect));
422-
if (pnode)
423-
{
424-
pnode->MaybeSetAddrName(std::string(pszDest));
420+
if (pnode) {
425421
LogPrintf("Failed to open new connection, already connected\n");
426422
return nullptr;
427423
}
@@ -539,14 +535,8 @@ std::string CNode::GetAddrName() const {
539535
return addrName;
540536
}
541537

542-
void CNode::MaybeSetAddrName(const std::string& addrNameIn) {
543-
LOCK(cs_addrName);
544-
if (addrName.empty()) {
545-
addrName = addrNameIn;
546-
}
547-
}
548-
549-
CService CNode::GetAddrLocal() const {
538+
CService CNode::GetAddrLocal() const
539+
{
550540
LOCK(cs_addrLocal);
551541
return addrLocal;
552542
}

src/net.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ class CNode
659659
}
660660

661661
std::string GetAddrName() const;
662-
//! Sets the addrName only if it was not previously set
663-
void MaybeSetAddrName(const std::string& addrNameIn);
664662

665663
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
666664

src/test/fuzz/net.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ FUZZ_TARGET_INIT(net, initialize_net)
3737
[&] {
3838
node.CloseSocketDisconnect();
3939
},
40-
[&] {
41-
node.MaybeSetAddrName(fuzzed_data_provider.ConsumeRandomLengthString(32));
42-
},
4340
[&] {
4441
const std::vector<bool> asmap = ConsumeRandomLengthBitVector(fuzzed_data_provider);
4542
if (!SanityCheckASMap(asmap)) {

0 commit comments

Comments
 (0)