mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
Merge bitcoin/bitcoin#25619: net: avoid overriding non-virtual ToString() in CService and use better naming
c9d548c91fnet: remove CService::ToStringPort() (Vasil Dimov)fd4f0f41e9gui: simplify OptionsDialog::updateDefaultProxyNets() (Vasil Dimov)96c791dd20net: remove CService::ToString() use ToStringAddrPort() instead (Vasil Dimov)944a9de08anet: remove CNetAddr::ToString() and use ToStringAddr() instead (Vasil Dimov)043b9de59ascripted-diff: rename ToStringIP[Port]() to ToStringAddr[Port]() (Vasil Dimov) Pull request description: Before this PR we had the somewhat confusing combination of methods: `CNetAddr::ToStringIP()` `CNetAddr::ToString()` (duplicate of the above) `CService::ToStringIPPort()` `CService::ToString()` (duplicate of the above, overrides a non-virtual method from `CNetAddr`) `CService::ToStringPort()` Avoid [overriding non-virtual methods](https://github.com/bitcoin/bitcoin/pull/25349/#issuecomment-1185226396). "IP" stands for "Internet Protocol" and while sometimes "IP addresses" are called just "IPs", it is incorrect to call Tor or I2P addresses "IPs". Thus use "Addr" instead of "IP". Change the above to: `CNetAddr::ToStringAddr()` `CService::ToStringAddrPort()` The changes touch a lot of files, but are mostly mechanical. ACKs for top commit: sipa: utACKc9d548c91fachow101: ACKc9d548c91fjonatack: re-ACKc9d548c91fonly change since my previous reviews is rebase, but as a sanity check rebased to current master and at each commit quickly re-reviewed and re-verified clean build and green unit tests LarryRuane: ACKc9d548c91fTree-SHA512: 633fb044bdecf9f551b5e3314c385bf10e2b78e8027dc51ec324b66b018da35e5b01f3fbe6295bbc455ea1bcd1a3629de1918d28de510693afaf6a52693f2157
This commit is contained in:
@@ -599,7 +599,7 @@ std::string OnionToString(Span<const uint8_t> addr)
|
||||
return EncodeBase32(address) + ".onion";
|
||||
}
|
||||
|
||||
std::string CNetAddr::ToStringIP() const
|
||||
std::string CNetAddr::ToStringAddr() const
|
||||
{
|
||||
switch (m_net) {
|
||||
case NET_IPV4:
|
||||
@@ -622,11 +622,6 @@ std::string CNetAddr::ToStringIP() const
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::string CNetAddr::ToString() const
|
||||
{
|
||||
return ToStringIP();
|
||||
}
|
||||
|
||||
bool operator==(const CNetAddr& a, const CNetAddr& b)
|
||||
{
|
||||
return a.m_net == b.m_net && a.m_addr == b.m_addr;
|
||||
@@ -916,25 +911,17 @@ std::vector<unsigned char> CService::GetKey() const
|
||||
return key;
|
||||
}
|
||||
|
||||
std::string CService::ToStringPort() const
|
||||
std::string CService::ToStringAddrPort() const
|
||||
{
|
||||
return strprintf("%u", port);
|
||||
}
|
||||
const auto port_str = strprintf("%u", port);
|
||||
|
||||
std::string CService::ToStringIPPort() const
|
||||
{
|
||||
if (IsIPv4() || IsTor() || IsI2P() || IsInternal()) {
|
||||
return ToStringIP() + ":" + ToStringPort();
|
||||
return ToStringAddr() + ":" + port_str;
|
||||
} else {
|
||||
return "[" + ToStringIP() + "]:" + ToStringPort();
|
||||
return "[" + ToStringAddr() + "]:" + port_str;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CService::ToString() const
|
||||
{
|
||||
return ToStringIPPort();
|
||||
}
|
||||
|
||||
CSubNet::CSubNet():
|
||||
valid(false)
|
||||
{
|
||||
@@ -1098,7 +1085,7 @@ std::string CSubNet::ToString() const
|
||||
break;
|
||||
}
|
||||
|
||||
return network.ToString() + suffix;
|
||||
return network.ToStringAddr() + suffix;
|
||||
}
|
||||
|
||||
bool CSubNet::IsValid() const
|
||||
|
||||
Reference in New Issue
Block a user