Skip to content

Commit

Permalink
net: avoid unnecessary GetBindAddress() call
Browse files Browse the repository at this point in the history
Summary:
Our local (bind) address is already saved in `CNode::addrBind` and there
is no need to re-retrieve it again with `GetBindAddress()`.

Also, for I2P connections `CNode::addrBind` would contain our I2P
address, but `GetBindAddress()` would return something like
`127.0.0.1:RANDOM_PORT`.

This is a backport of [[bitcoin/bitcoin#20685 | core#20685]] [7/20]
bitcoin/bitcoin@f6c267d

Depends on D11015

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11016
  • Loading branch information
vasild authored and PiRK committed Feb 10, 2022
1 parent fb406d6 commit 1e55ff3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3152,9 +3152,7 @@ std::vector<CAddress> CConnman::GetAddresses(size_t max_addresses,

std::vector<CAddress>
CConnman::GetAddresses(CNode &requestor, size_t max_addresses, size_t max_pct) {
SOCKET socket;
WITH_LOCK(requestor.cs_hSocket, socket = requestor.hSocket);
auto local_socket_bytes = GetBindAddress(socket).GetAddrBytes();
auto local_socket_bytes = requestor.addrBind.GetAddrBytes();
uint64_t cache_id =
GetDeterministicRandomizer(RANDOMIZER_ID_ADDRCACHE)
.Write(requestor.addr.GetNetwork())
Expand Down

0 comments on commit 1e55ff3

Please sign in to comment.