aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2020-11-24 15:36:27 +0100
committerVasil Dimov <vd@FreeBSD.org>2021-03-01 12:57:01 +0100
commitf6c267db3be2d7077fd2bdbd34860eba838dea99 (patch)
treedd2a7126aea151c39442993404002e84a02b75f8
parent7c224fdac4699a2c4953b33ab423f9cddbf95cf7 (diff)
net: avoid unnecessary GetBindAddress() call
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`.
-rw-r--r--src/net.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 6109fc4e5a..d03e3cac37 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2606,9 +2606,7 @@ std::vector<CAddress> CConnman::GetAddresses(size_t max_addresses, size_t max_pc
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())
.Write(local_socket_bytes.data(), local_socket_bytes.size())