2019-01-22 01:14:02 +00:00
|
|
|
#include <dht/explorenetworkjob.hpp>
|
|
|
|
|
|
|
|
#include <dht/context.hpp>
|
|
|
|
#include <dht/messages/findrouter.hpp>
|
2019-02-11 19:45:42 +00:00
|
|
|
#include <router/abstractrouter.hpp>
|
2019-01-22 01:14:02 +00:00
|
|
|
|
2020-02-07 18:19:00 +00:00
|
|
|
#include <nodedb.hpp>
|
|
|
|
|
2020-03-10 18:12:11 +00:00
|
|
|
#include <tooling/dht_event.hpp>
|
|
|
|
|
2019-01-22 01:14:02 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
ExploreNetworkJob::Start(const TXOwner& peer)
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
2020-03-10 18:12:11 +00:00
|
|
|
auto msg = new FindRouterMessage(peer.txid);
|
|
|
|
auto router = parent->GetRouter();
|
2020-04-18 19:58:41 +00:00
|
|
|
if (router)
|
|
|
|
{
|
|
|
|
router->NotifyRouterEvent<tooling::FindRouterSentEvent>(router->pubkey(), *msg);
|
|
|
|
}
|
2020-03-10 18:12:11 +00:00
|
|
|
parent->DHTSendTo(peer.node.as_array(), msg);
|
2019-01-22 01:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExploreNetworkJob::SendReply()
|
|
|
|
{
|
2019-07-17 12:25:51 +00:00
|
|
|
llarp::LogDebug("got ", valuesFound.size(), " routers from exploration");
|
2019-01-22 23:50:26 +00:00
|
|
|
|
|
|
|
auto router = parent->GetRouter();
|
|
|
|
using std::placeholders::_1;
|
2020-04-07 18:38:56 +00:00
|
|
|
for (const auto& pk : valuesFound)
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
|
|
|
// lookup router
|
2020-04-07 18:38:56 +00:00
|
|
|
if (router and router->nodedb()->Has(pk))
|
2020-02-07 18:19:00 +00:00
|
|
|
continue;
|
2019-01-22 01:14:02 +00:00
|
|
|
parent->LookupRouter(
|
2020-04-07 18:38:56 +00:00
|
|
|
pk, std::bind(&AbstractRouter::HandleDHTLookupForExplore, router, pk, _1));
|
2019-01-22 01:14:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|