diff --git a/llarp/dht/explorenetworkjob.hpp b/llarp/dht/explorenetworkjob.hpp index d88b6b9cc..598fc663a 100644 --- a/llarp/dht/explorenetworkjob.hpp +++ b/llarp/dht/explorenetworkjob.hpp @@ -25,17 +25,6 @@ namespace llarp void Start(const TXOwner &peer) override; - bool - GetNextPeer(Key_t &, const std::set< Key_t > &) override - { - return false; - } - - void - DoNextRequest(const Key_t &) override - { - } - void SendReply() override; }; diff --git a/llarp/dht/publishservicejob.hpp b/llarp/dht/publishservicejob.hpp index 77330ef3e..c7d108ab9 100644 --- a/llarp/dht/publishservicejob.hpp +++ b/llarp/dht/publishservicejob.hpp @@ -29,17 +29,6 @@ namespace llarp void Start(const TXOwner &peer) override; - bool - GetNextPeer(Key_t &, const std::set< Key_t > &) override - { - return false; - } - - void - DoNextRequest(const Key_t &) override - { - } - void SendReply() override { diff --git a/llarp/dht/recursiverouterlookup.cpp b/llarp/dht/recursiverouterlookup.cpp index 1a7cadf86..b92c6ef17 100644 --- a/llarp/dht/recursiverouterlookup.cpp +++ b/llarp/dht/recursiverouterlookup.cpp @@ -35,21 +35,6 @@ namespace llarp return true; } - bool - RecursiveRouterLookup::GetNextPeer(Key_t &nextPeer, - const std::set< Key_t > &exclude) - { - const Key_t K(target.as_array()); - return parent->Nodes()->FindCloseExcluding(K, nextPeer, exclude); - } - - void - RecursiveRouterLookup::DoNextRequest(const Key_t &peer) - { - parent->LookupRouterRecursive(target, whoasked.node, whoasked.txid, peer, - resultHandler); - } - void RecursiveRouterLookup::Start(const TXOwner &peer) { diff --git a/llarp/dht/recursiverouterlookup.hpp b/llarp/dht/recursiverouterlookup.hpp index b7f56e063..37c3162d4 100644 --- a/llarp/dht/recursiverouterlookup.hpp +++ b/llarp/dht/recursiverouterlookup.hpp @@ -19,12 +19,6 @@ namespace llarp bool Validate(const RouterContact &rc) const override; - bool - GetNextPeer(Key_t &nextPeer, const std::set< Key_t > &exclude) override; - - void - DoNextRequest(const Key_t &peer) override; - void Start(const TXOwner &peer) override; diff --git a/llarp/dht/serviceaddresslookup.cpp b/llarp/dht/serviceaddresslookup.cpp index b00be7ea6..317c3c7ef 100644 --- a/llarp/dht/serviceaddresslookup.cpp +++ b/llarp/dht/serviceaddresslookup.cpp @@ -36,19 +36,6 @@ namespace llarp return true; } - bool - ServiceAddressLookup::GetNextPeer(Key_t &next, - const std::set< Key_t > &exclude) - { - const auto &nodes = parent->Nodes(); - if(nodes) - { - return nodes->FindCloseExcluding(target, next, exclude); - } - - return false; - } - void ServiceAddressLookup::Start(const TXOwner &peer) { @@ -56,13 +43,6 @@ namespace llarp new FindIntroMessage(peer.txid, target, relayOrder)); } - void - ServiceAddressLookup::DoNextRequest(const Key_t &ask) - { - (void)ask; - // do nothing -- we handle propagating this explicitly - } - void ServiceAddressLookup::SendReply() { diff --git a/llarp/dht/serviceaddresslookup.hpp b/llarp/dht/serviceaddresslookup.hpp index e2c0bf1d1..bdf8274f9 100644 --- a/llarp/dht/serviceaddresslookup.hpp +++ b/llarp/dht/serviceaddresslookup.hpp @@ -24,15 +24,9 @@ namespace llarp bool Validate(const service::EncryptedIntroSet &value) const override; - bool - GetNextPeer(Key_t &next, const std::set< Key_t > &exclude) override; - void Start(const TXOwner &peer) override; - void - DoNextRequest(const Key_t &ask) override; - void SendReply() override; }; diff --git a/llarp/dht/taglookup.hpp b/llarp/dht/taglookup.hpp index 88c3dfd95..954c0ec60 100644 --- a/llarp/dht/taglookup.hpp +++ b/llarp/dht/taglookup.hpp @@ -25,17 +25,6 @@ namespace llarp void Start(const TXOwner &peer) override; - bool - GetNextPeer(Key_t &, const std::set< Key_t > &) override - { - return false; - } - - void - DoNextRequest(const Key_t &) override - { - } - void SendReply() override; }; diff --git a/llarp/dht/tx.hpp b/llarp/dht/tx.hpp index 83ad20873..9c0b53ca2 100644 --- a/llarp/dht/tx.hpp +++ b/llarp/dht/tx.hpp @@ -34,10 +34,6 @@ namespace llarp void OnFound(const Key_t& askedPeer, const V& value); - /// return true if we want to persist this tx - bool - AskNextPeer(const Key_t& prevPeer, const std::unique_ptr< Key_t >& next); - util::StatusObject ExtractStatus() const { @@ -65,12 +61,6 @@ namespace llarp virtual void Start(const TXOwner& peer) = 0; - virtual bool - GetNextPeer(Key_t& next, const std::set< Key_t >& exclude) = 0; - - virtual void - DoNextRequest(const Key_t& peer) = 0; - virtual void SendReply() = 0; }; @@ -85,39 +75,6 @@ namespace llarp valuesFound.push_back(value); } } - - template < typename K, typename V > - inline bool - TX< K, V >::AskNextPeer(const Key_t& prevPeer, - const std::unique_ptr< Key_t >& next) - { - peersAsked.insert(prevPeer); - Key_t peer; - if(next) - { - // explicit next peer provided - peer = *next; - } - else if(GetNextPeer(peer, peersAsked)) - { - const Key_t targetKey{target}; - if((prevPeer ^ targetKey) < (peer ^ targetKey)) - { - // next peer is not closer - llarp::LogDebug("next peer ", peer.SNode(), " is not closer to ", - target, " than ", prevPeer.SNode()); - return false; - } - } - else - { - llarp::LogDebug("no more peers for request asking for ", target); - return false; - } - peersAsked.insert(peer); - DoNextRequest(peer); - return true; - } } // namespace dht } // namespace llarp diff --git a/test/dht/test_llarp_dht_explorenetworkjob.cpp b/test/dht/test_llarp_dht_explorenetworkjob.cpp index 9946cba05..2fc683afe 100644 --- a/test/dht/test_llarp_dht_explorenetworkjob.cpp +++ b/test/dht/test_llarp_dht_explorenetworkjob.cpp @@ -29,19 +29,6 @@ TEST_F(TestDhtExploreNetworkJob, validate) ASSERT_TRUE(exploreNetworkJob.Validate(other)); } -TEST_F(TestDhtExploreNetworkJob, get_next_peer) -{ - dht::Key_t key = makeBuf< dht::Key_t >(0x02); - std::set< dht::Key_t > exclude; - ASSERT_FALSE(exploreNetworkJob.GetNextPeer(key, exclude)); -} - -TEST_F(TestDhtExploreNetworkJob, do_next) -{ - const dht::Key_t key = makeBuf< dht::Key_t >(0x02); - ASSERT_NO_THROW(exploreNetworkJob.DoNextRequest(key)); -} - TEST_F(TestDhtExploreNetworkJob, start) { // Verify input arguments are passed correctly. diff --git a/test/dht/test_llarp_dht_tx.cpp b/test/dht/test_llarp_dht_tx.cpp index 7303ae510..cf88085c6 100644 --- a/test/dht/test_llarp_dht_tx.cpp +++ b/test/dht/test_llarp_dht_tx.cpp @@ -25,10 +25,6 @@ struct TestTx final : public dht::TX< dht::Key_t, Val_t > MOCK_METHOD1(Start, void(const dht::TXOwner&)); - MOCK_METHOD2(GetNextPeer, bool(dht::Key_t&, const std::set< dht::Key_t >&)); - - MOCK_METHOD1(DoNextRequest, void(const dht::Key_t&)); - MOCK_METHOD0(SendReply, void()); }; @@ -107,65 +103,3 @@ TEST_F(TestDhtTx, on_found) } } -TEST_F(TestDhtTx, ask_next_peer) -{ - // Concerns: - // - GetNextPeer fails - // - Next Peer is not closer - // - next ptr is null - // - next ptr is not null - - const auto key0 = makeBuf< dht::Key_t >(0x00); - const auto key1 = makeBuf< dht::Key_t >(0x01); - const auto key2 = makeBuf< dht::Key_t >(0x02); - { - // GetNextPeer fails - EXPECT_CALL(tx, GetNextPeer(_, _)).WillOnce(Return(false)); - - EXPECT_CALL(tx, DoNextRequest(key1)).Times(0); - - ASSERT_FALSE(tx.AskNextPeer(key0, {})); - ASSERT_THAT(tx.peersAsked, Contains(key0)); - - tx.peersAsked.clear(); - } - - { - // Next Peer is not closer - EXPECT_CALL(tx, GetNextPeer(_, _)) - .WillOnce(DoAll(SetArgReferee< 0 >(key1), Return(true))); - - EXPECT_CALL(tx, DoNextRequest(key1)).Times(0); - - ASSERT_FALSE(tx.AskNextPeer(key0, {})); - ASSERT_THAT(tx.peersAsked, Contains(key0)); - - tx.peersAsked.clear(); - } - - { - // next ptr is null - EXPECT_CALL(tx, GetNextPeer(_, _)) - .WillOnce(DoAll(SetArgReferee< 0 >(key1), Return(true))); - - EXPECT_CALL(tx, DoNextRequest(key1)).Times(1); - - ASSERT_TRUE(tx.AskNextPeer(key2, {})); - ASSERT_THAT(tx.peersAsked, Contains(key2)); - - tx.peersAsked.clear(); - } - - { - // next ptr is not null - EXPECT_CALL(tx, GetNextPeer(_, _)).Times(0); - - EXPECT_CALL(tx, DoNextRequest(key1)).Times(1); - - auto ptr = std::make_unique< dht::Key_t >(key1); - ASSERT_TRUE(tx.AskNextPeer(key2, ptr)); - ASSERT_THAT(tx.peersAsked, Contains(key2)); - - tx.peersAsked.clear(); - } -}