MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / Explore

Method Explore

libi2pd/NetDbRequests.cpp:459–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457 }
458
459 void NetDbRequests::Explore (int numDestinations)
460 {
461 // new requests
462 auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
463 auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr;
464 auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr;
465 bool throughTunnels = outbound && inbound;
466
467 uint8_t randomHash[32];
468 std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
469 LogPrint (eLogInfo, "NetDbReq: Exploring new ", numDestinations, " routers ...");
470 for (int i = 0; i < numDestinations; i++)
471 {
472 RAND_bytes (randomHash, 32);
473 auto dest = CreateRequest (randomHash, true, !throughTunnels); // exploratory
474 if (!dest)
475 {
476 LogPrint (eLogWarning, "NetDbReq: Exploratory destination is requested already");
477 return;
478 }
479 auto floodfill = netdb.GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
480 if (floodfill)
481 {
482 if (i2p::transport::transports.IsConnected (floodfill->GetIdentHash ()))
483 throughTunnels = false;
484 if (throughTunnels)
485 {
486 msgs.push_back (i2p::tunnel::TunnelMessageBlock
487 {
488 i2p::tunnel::eDeliveryTypeRouter,
489 floodfill->GetIdentHash (), 0,
490 CreateDatabaseStoreMsg () // tell floodfill about us
491 });
492 msgs.push_back (i2p::tunnel::TunnelMessageBlock
493 {
494 i2p::tunnel::eDeliveryTypeRouter,
495 floodfill->GetIdentHash (), 0,
496 dest->CreateRequestMessage (floodfill, inbound) // explore
497 });
498 }
499 else
500 i2p::transport::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
501 }
502 else
503 RequestComplete (randomHash, nullptr);
504 }
505 if (throughTunnels && msgs.size () > 0)
506 outbound->SendTunnelDataMsgs (msgs);
507 }
508
509 void NetDbRequests::ScheduleExploratory (uint64_t interval)
510 {

Callers

nothing calls this directly

Calls 11

LogPrintFunction · 0.85
CreateDatabaseStoreMsgFunction · 0.85
GetExploratoryPoolMethod · 0.80
GetClosestFloodfillMethod · 0.80
push_backMethod · 0.80
CreateRequestMessageMethod · 0.80
SendMessageMethod · 0.80
SendTunnelDataMsgsMethod · 0.80
GetNextOutboundTunnelMethod · 0.45
GetNextInboundTunnelMethod · 0.45
IsConnectedMethod · 0.45

Tested by

no test coverage detected