mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +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:
@@ -486,7 +486,7 @@ void AddrManImpl::ClearNew(int nUBucket, int nUBucketPos)
|
||||
assert(infoDelete.nRefCount > 0);
|
||||
infoDelete.nRefCount--;
|
||||
vvNew[nUBucket][nUBucketPos] = -1;
|
||||
LogPrint(BCLog::ADDRMAN, "Removed %s from new[%i][%i]\n", infoDelete.ToString(), nUBucket, nUBucketPos);
|
||||
LogPrint(BCLog::ADDRMAN, "Removed %s from new[%i][%i]\n", infoDelete.ToStringAddrPort(), nUBucket, nUBucketPos);
|
||||
if (infoDelete.nRefCount == 0) {
|
||||
Delete(nIdDelete);
|
||||
}
|
||||
@@ -542,7 +542,7 @@ void AddrManImpl::MakeTried(AddrInfo& info, int nId)
|
||||
nNew++;
|
||||
m_network_counts[infoOld.GetNetwork()].n_new++;
|
||||
LogPrint(BCLog::ADDRMAN, "Moved %s from tried[%i][%i] to new[%i][%i] to make space\n",
|
||||
infoOld.ToString(), nKBucket, nKBucketPos, nUBucket, nUBucketPos);
|
||||
infoOld.ToStringAddrPort(), nKBucket, nKBucketPos, nUBucket, nUBucketPos);
|
||||
}
|
||||
assert(vvTried[nKBucket][nKBucketPos] == -1);
|
||||
|
||||
@@ -618,7 +618,7 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, std::c
|
||||
pinfo->nRefCount++;
|
||||
vvNew[nUBucket][nUBucketPos] = nId;
|
||||
LogPrint(BCLog::ADDRMAN, "Added %s mapped to AS%i to new[%i][%i]\n",
|
||||
addr.ToString(), m_netgroupman.GetMappedAS(addr), nUBucket, nUBucketPos);
|
||||
addr.ToStringAddrPort(), m_netgroupman.GetMappedAS(addr), nUBucket, nUBucketPos);
|
||||
} else {
|
||||
if (pinfo->nRefCount == 0) {
|
||||
Delete(nId);
|
||||
@@ -669,15 +669,15 @@ bool AddrManImpl::Good_(const CService& addr, bool test_before_evict, NodeSecond
|
||||
// Output the entry we'd be colliding with, for debugging purposes
|
||||
auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]);
|
||||
LogPrint(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d\n",
|
||||
colliding_entry != mapInfo.end() ? colliding_entry->second.ToString() : "",
|
||||
addr.ToString(),
|
||||
colliding_entry != mapInfo.end() ? colliding_entry->second.ToStringAddrPort() : "",
|
||||
addr.ToStringAddrPort(),
|
||||
m_tried_collisions.size());
|
||||
return false;
|
||||
} else {
|
||||
// move nId to the tried tables
|
||||
MakeTried(info, nId);
|
||||
LogPrint(BCLog::ADDRMAN, "Moved %s mapped to AS%i to tried[%i][%i]\n",
|
||||
addr.ToString(), m_netgroupman.GetMappedAS(addr), tried_bucket, tried_bucket_pos);
|
||||
addr.ToStringAddrPort(), m_netgroupman.GetMappedAS(addr), tried_bucket, tried_bucket_pos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -689,7 +689,7 @@ bool AddrManImpl::Add_(const std::vector<CAddress>& vAddr, const CNetAddr& sourc
|
||||
added += AddSingle(*it, source, time_penalty) ? 1 : 0;
|
||||
}
|
||||
if (added > 0) {
|
||||
LogPrint(BCLog::ADDRMAN, "Added %i addresses (of %i) from %s: %i tried, %i new\n", added, vAddr.size(), source.ToString(), nTried, nNew);
|
||||
LogPrint(BCLog::ADDRMAN, "Added %i addresses (of %i) from %s: %i tried, %i new\n", added, vAddr.size(), source.ToStringAddr(), nTried, nNew);
|
||||
}
|
||||
return added > 0;
|
||||
}
|
||||
@@ -746,7 +746,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool newOnly) const
|
||||
const AddrInfo& info{it_found->second};
|
||||
// With probability GetChance() * fChanceFactor, return the entry.
|
||||
if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30)) {
|
||||
LogPrint(BCLog::ADDRMAN, "Selected %s from tried\n", info.ToString());
|
||||
LogPrint(BCLog::ADDRMAN, "Selected %s from tried\n", info.ToStringAddrPort());
|
||||
return {info, info.m_last_try};
|
||||
}
|
||||
// Otherwise start over with a (likely) different bucket, and increased chance factor.
|
||||
@@ -774,7 +774,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool newOnly) const
|
||||
const AddrInfo& info{it_found->second};
|
||||
// With probability GetChance() * fChanceFactor, return the entry.
|
||||
if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30)) {
|
||||
LogPrint(BCLog::ADDRMAN, "Selected %s from new\n", info.ToString());
|
||||
LogPrint(BCLog::ADDRMAN, "Selected %s from new\n", info.ToStringAddrPort());
|
||||
return {info, info.m_last_try};
|
||||
}
|
||||
// Otherwise start over with a (likely) different bucket, and increased chance factor.
|
||||
@@ -891,7 +891,7 @@ void AddrManImpl::ResolveCollisions_()
|
||||
|
||||
// Give address at least 60 seconds to successfully connect
|
||||
if (current_time - info_old.m_last_try > 60s) {
|
||||
LogPrint(BCLog::ADDRMAN, "Replacing %s with %s in tried table\n", info_old.ToString(), info_new.ToString());
|
||||
LogPrint(BCLog::ADDRMAN, "Replacing %s with %s in tried table\n", info_old.ToStringAddrPort(), info_new.ToStringAddrPort());
|
||||
|
||||
// Replaces an existing address already in the tried table with the new address
|
||||
Good_(info_new, false, current_time);
|
||||
@@ -901,7 +901,7 @@ void AddrManImpl::ResolveCollisions_()
|
||||
// If the collision hasn't resolved in some reasonable amount of time,
|
||||
// just evict the old entry -- we must not be able to
|
||||
// connect to it for some reason.
|
||||
LogPrint(BCLog::ADDRMAN, "Unable to test; replacing %s with %s in tried table anyway\n", info_old.ToString(), info_new.ToString());
|
||||
LogPrint(BCLog::ADDRMAN, "Unable to test; replacing %s with %s in tried table anyway\n", info_old.ToStringAddrPort(), info_new.ToStringAddrPort());
|
||||
Good_(info_new, false, current_time);
|
||||
erase_collision = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user