mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
improve exploratory
This commit is contained in:
parent
f8d105551f
commit
103be652ab
38
NetDb.cpp
38
NetDb.cpp
|
@ -448,10 +448,18 @@ namespace data
|
||||||
{
|
{
|
||||||
auto r = FindRouter (router);
|
auto r = FindRouter (router);
|
||||||
// do we have that floodfill router in our database?
|
// do we have that floodfill router in our database?
|
||||||
if (r)
|
if (r)
|
||||||
{
|
{
|
||||||
|
// we do
|
||||||
if (!dest->IsExcluded (r->GetIdentHash ()) && dest->GetNumExcludedPeers () < 30) // TODO: fix TunnelGateway first
|
if (!dest->IsExcluded (r->GetIdentHash ()) && dest->GetNumExcludedPeers () < 30) // TODO: fix TunnelGateway first
|
||||||
{
|
{
|
||||||
|
// tell floodfill about us
|
||||||
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
|
{
|
||||||
|
i2p::tunnel::eDeliveryTypeRouter,
|
||||||
|
r->GetIdentHash (), 0,
|
||||||
|
CreateDatabaseStoreMsg ()
|
||||||
|
});
|
||||||
// request destination
|
// request destination
|
||||||
auto msg = dest->CreateRequestMessage (r, dest->GetLastReplyTunnel ());
|
auto msg = dest->CreateRequestMessage (r, dest->GetLastReplyTunnel ());
|
||||||
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
|
@ -506,16 +514,15 @@ namespace data
|
||||||
auto inbound = i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
auto inbound = i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
||||||
if (outbound && inbound)
|
if (outbound && inbound)
|
||||||
{
|
{
|
||||||
auto floodfill = GetRandomRouter (outbound->GetEndpointRouter (), true);
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
|
uint8_t randomHash[32];
|
||||||
|
rnd.GenerateBlock (randomHash, 32);
|
||||||
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true);
|
||||||
|
dest->SetLastOutboundTunnel (outbound);
|
||||||
|
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
|
||||||
if (floodfill)
|
if (floodfill)
|
||||||
{
|
{
|
||||||
LogPrint ("Exploring new routers ...");
|
LogPrint ("Exploring new routers ...");
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
|
||||||
uint8_t randomHash[32];
|
|
||||||
rnd.GenerateBlock (randomHash, 32);
|
|
||||||
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true);
|
|
||||||
dest->SetLastOutboundTunnel (outbound);
|
|
||||||
|
|
||||||
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
||||||
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
{
|
{
|
||||||
|
@ -529,8 +536,10 @@ namespace data
|
||||||
floodfill->GetIdentHash (), 0,
|
floodfill->GetIdentHash (), 0,
|
||||||
dest->CreateRequestMessage (floodfill, inbound) // explore
|
dest->CreateRequestMessage (floodfill, inbound) // explore
|
||||||
});
|
});
|
||||||
outbound->SendTunnelDataMsg (msgs);
|
outbound->SendTunnelDataMsg (msgs);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
DeleteRequestedDestination (dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,6 +566,15 @@ namespace data
|
||||||
m_RequestedDestinations.erase (it);
|
m_RequestedDestinations.erase (it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetDb::DeleteRequestedDestination (RequestedDestination * dest)
|
||||||
|
{
|
||||||
|
if (dest)
|
||||||
|
{
|
||||||
|
m_RequestedDestinations.erase (dest->GetDestination ());
|
||||||
|
delete dest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const RouterInfo * NetDb::GetRandomNTCPRouter (bool floodfillOnly) const
|
const RouterInfo * NetDb::GetRandomNTCPRouter (bool floodfillOnly) const
|
||||||
{
|
{
|
||||||
|
|
1
NetDb.h
1
NetDb.h
|
@ -87,6 +87,7 @@ namespace data
|
||||||
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
||||||
bool isLeaseSet, bool isExploratory = false);
|
bool isLeaseSet, bool isExploratory = false);
|
||||||
void DeleteRequestedDestination (const IdentHash& dest);
|
void DeleteRequestedDestination (const IdentHash& dest);
|
||||||
|
void DeleteRequestedDestination (RequestedDestination * dest);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue