Judicious removal of dead code

This commit is contained in:
Stephen Shelton 2020-02-28 10:18:09 -07:00
parent f293d4d783
commit 6b906de00d
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C
10 changed files with 0 additions and 202 deletions

View File

@ -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;
};

View File

@ -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
{

View File

@ -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)
{

View File

@ -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;

View File

@ -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()
{

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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

View File

@ -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.

View File

@ -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();
}
}