net: merge AlreadyConnectedToAddress() and FindNode(CNetAddr)

`CConnman::AlreadyConnectedToAddress()` is the only caller of
`CConnman::FindNode(CNetAddr)`, so merge the two in one function.

The unit test that checked whether `AlreadyConnectedToAddress()` ignores
the port is now unnecessary because now the function takes a `CNetAddr`
argument. It has no access to the port.
This commit is contained in:
Vasil Dimov
2025-04-22 12:15:32 +02:00
parent d8fe258cd6
commit 3a4d1a25cf
4 changed files with 8 additions and 27 deletions

View File

@@ -151,15 +151,8 @@ BOOST_FIXTURE_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection,
}
BOOST_TEST_MESSAGE("\nCheck that all connected peers are correctly detected as connected");
for (auto node : connman->TestNodes()) {
BOOST_CHECK(connman->AlreadyConnectedPublic(node->addr));
}
BOOST_TEST_MESSAGE("\nCheck that peers with the same addresses as connected peers but different ports are detected as connected.");
for (auto node : connman->TestNodes()) {
uint16_t changed_port = node->addr.GetPort() + 1;
CService address_with_changed_port{node->addr, changed_port};
BOOST_CHECK(connman->AlreadyConnectedPublic(CAddress{address_with_changed_port, NODE_NONE}));
for (const auto& node : connman->TestNodes()) {
BOOST_CHECK(connman->AlreadyConnectedToAddressPublic(node->addr));
}
// Clean up