mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
better exploratory
This commit is contained in:
parent
5d9f292506
commit
ca51567eba
20
NetDb.cpp
20
NetDb.cpp
@ -270,8 +270,8 @@ namespace data
|
|||||||
if (num > 0)
|
if (num > 0)
|
||||||
{
|
{
|
||||||
bool isExploratory = !memcmp (m_Exploratory, buf, 32) && m_LastFloodfill;
|
bool isExploratory = !memcmp (m_Exploratory, buf, 32) && m_LastFloodfill;
|
||||||
i2p::tunnel::OutboundTunnel * outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel ();
|
i2p::tunnel::OutboundTunnel * outbound = isExploratory ? m_LastOutboundTunnel : i2p::tunnel::tunnels.GetNextOutboundTunnel ();
|
||||||
i2p::tunnel::InboundTunnel * inbound = i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
i2p::tunnel::InboundTunnel * inbound = isExploratory ? m_LastInboundTunnel : i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
||||||
|
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
@ -327,9 +327,9 @@ namespace data
|
|||||||
|
|
||||||
void NetDb::Explore ()
|
void NetDb::Explore ()
|
||||||
{
|
{
|
||||||
i2p::tunnel::OutboundTunnel * outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel ();
|
m_LastOutboundTunnel = i2p::tunnel::tunnels.GetNextOutboundTunnel ();
|
||||||
i2p::tunnel::InboundTunnel * inbound = i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
m_LastInboundTunnel = i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
||||||
if (outbound && inbound)
|
if (m_LastOutboundTunnel && m_LastInboundTunnel)
|
||||||
{
|
{
|
||||||
m_LastFloodfill = GetRandomNTCPRouter (true);
|
m_LastFloodfill = GetRandomNTCPRouter (true);
|
||||||
if (m_LastFloodfill)
|
if (m_LastFloodfill)
|
||||||
@ -337,9 +337,13 @@ namespace data
|
|||||||
LogPrint ("Exploring new routers ...");
|
LogPrint ("Exploring new routers ...");
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
rnd.GenerateBlock (m_Exploratory, 32);
|
rnd.GenerateBlock (m_Exploratory, 32);
|
||||||
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (m_Exploratory, inbound->GetNextIdentHash (),
|
|
||||||
inbound->GetNextTunnelID (), true);
|
m_LastOutboundTunnel->GetTunnelGateway ().PutTunnelDataMsg (m_LastFloodfill->GetIdentHash (), 0,
|
||||||
outbound->SendTunnelDataMsg (m_LastFloodfill->GetIdentHash (), 0, msg);
|
CreateDatabaseStoreMsg ()); // tell floodfill about us
|
||||||
|
m_LastOutboundTunnel->GetTunnelGateway ().PutTunnelDataMsg (m_LastFloodfill->GetIdentHash (), 0,
|
||||||
|
i2p::CreateDatabaseLookupMsg (m_Exploratory, m_LastInboundTunnel->GetNextIdentHash (),
|
||||||
|
m_LastInboundTunnel->GetNextTunnelID (), true)); // explore
|
||||||
|
m_LastOutboundTunnel->GetTunnelGateway ().SendBuffer ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
NetDb.h
3
NetDb.h
@ -9,6 +9,7 @@
|
|||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
#include "LeaseSet.h"
|
#include "LeaseSet.h"
|
||||||
|
#include "Tunnel.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
@ -57,6 +58,8 @@ namespace data
|
|||||||
std::thread * m_Thread;
|
std::thread * m_Thread;
|
||||||
uint8_t m_Exploratory[32];
|
uint8_t m_Exploratory[32];
|
||||||
const RouterInfo * m_LastFloodfill;
|
const RouterInfo * m_LastFloodfill;
|
||||||
|
i2p::tunnel::OutboundTunnel * m_LastOutboundTunnel;
|
||||||
|
i2p::tunnel::InboundTunnel * m_LastInboundTunnel;
|
||||||
i2p::util::Queue<I2NPMessage> m_Queue; // of I2NPDatabaseStoreMsg
|
i2p::util::Queue<I2NPMessage> m_Queue; // of I2NPDatabaseStoreMsg
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user