From f3160fcec9994775d5b6e64d4004a87a710be962 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Wed, 14 Apr 2021 18:48:13 -0400
Subject: [PATCH] jamiaccount: remove publicAddresses()

Change-Id: I26d9aa3c80e3a5330bf43a2f391bd45c3bb4a44a
---
 src/jamidht/jamiaccount.cpp | 13 -------------
 src/jamidht/jamiaccount.h   |  2 --
 src/jamidht/p2p.cpp         | 11 +----------
 3 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index 4d01aace0c..cbf1c3a346 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -3729,19 +3729,6 @@ JamiAccount::storeActiveIpAddress()
     }
 }
 
-std::vector<std::string>
-JamiAccount::publicAddresses()
-{
-    std::vector<std::string> addresses;
-    for (auto& addr : dht_->getPublicAddress(AF_INET)) {
-        addresses.emplace_back(addr.toString());
-    }
-    for (auto& addr : dht_->getPublicAddress(AF_INET6)) {
-        addresses.emplace_back(addr.toString());
-    }
-    return addresses;
-}
-
 void
 JamiAccount::requestPeerConnection(
     const std::string& peer_id,
diff --git a/src/jamidht/jamiaccount.h b/src/jamidht/jamiaccount.h
index 103bc2e64f..434e43f804 100644
--- a/src/jamidht/jamiaccount.h
+++ b/src/jamidht/jamiaccount.h
@@ -394,8 +394,6 @@ public:
     ///
     void closePeerConnection(const DRing::DataTransferId& tid);
 
-    std::vector<std::string> publicAddresses();
-
     /// \return true if the given DHT message identifier has been treated
     /// \note if message has not been treated yet this method store this id and returns true at
     /// further calls
diff --git a/src/jamidht/p2p.cpp b/src/jamidht/p2p.cpp
index 4df8168ca8..6c8fdb66bf 100644
--- a/src/jamidht/p2p.cpp
+++ b/src/jamidht/p2p.cpp
@@ -274,18 +274,9 @@ DhtPeerConnector::requestConnection(
         return;
     }
 
-    // Notes for reader:
-    // 1) dht.getPublicAddress() suffers of a non-usability into forEachDevice() callbacks.
-    //    If you call it in forEachDevice callbacks, it'll never not return...
-    //    Seems that getPublicAddress() and forEachDevice() need to process into the same thread
-    //    (here the one where dht_ loop runs).
-    // 2) anyway its good to keep this processing here in case of multiple device
-    //    as the result is the same for each device.
-    auto addresses = acc->publicAddresses();
-
     acc->forEachDevice(
         peer_h,
-        [this, addresses, tid, channelReadyCb = std::move(channelReadyCb)](
+        [this, tid, channelReadyCb = std::move(channelReadyCb)](
             const dht::InfoHash& dev_h) {
             auto acc = pimpl_->account.lock();
             if (!acc)
-- 
GitLab