mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
request destination in netdb requests thread
This commit is contained in:
parent
927123188c
commit
b75e418879
@ -807,14 +807,10 @@ namespace data
|
|||||||
void NetDb::RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete, bool direct)
|
void NetDb::RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete, bool direct)
|
||||||
{
|
{
|
||||||
if (direct && i2p::transport::transports.RoutesRestricted ()) direct = false; // always use tunnels for restricted routes
|
if (direct && i2p::transport::transports.RoutesRestricted ()) direct = false; // always use tunnels for restricted routes
|
||||||
auto dest = m_Requests->CreateRequest (destination, false, direct, requestComplete); // non-exploratory
|
if (m_Requests)
|
||||||
if (dest)
|
m_Requests->PostRequestDestination (destination, requestComplete, direct);
|
||||||
{
|
|
||||||
if (!m_Requests->SendNextRequest (dest))
|
|
||||||
m_Requests->RequestComplete (destination, nullptr);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "NetDb: Destination ", destination.ToBase64(), " is requested already or cached");
|
LogPrint (eLogError, "NetDb: Requests is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDb::RequestDestinationFrom (const IdentHash& destination, const IdentHash & from, bool exploratory, RequestedDestination::RequestComplete requestComplete)
|
void NetDb::RequestDestinationFrom (const IdentHash& destination, const IdentHash & from, bool exploratory, RequestedDestination::RequestComplete requestComplete)
|
||||||
|
@ -405,7 +405,7 @@ namespace data
|
|||||||
/* if(m_FloodfillBootstrap)
|
/* if(m_FloodfillBootstrap)
|
||||||
RequestDestinationFrom(router, m_FloodfillBootstrap->GetIdentHash(), true);
|
RequestDestinationFrom(router, m_FloodfillBootstrap->GetIdentHash(), true);
|
||||||
else */if (!IsRouterBanned (router))
|
else */if (!IsRouterBanned (router))
|
||||||
netdb.RequestDestination (router);
|
RequestDestination (router, nullptr, true);
|
||||||
else
|
else
|
||||||
LogPrint (eLogDebug, "NetDbReq: Router ", peerHash, " is banned. Skipped");
|
LogPrint (eLogDebug, "NetDbReq: Router ", peerHash, " is banned. Skipped");
|
||||||
}
|
}
|
||||||
@ -413,5 +413,26 @@ namespace data
|
|||||||
LogPrint (eLogDebug, "NetDbReq: [:|||:]");
|
LogPrint (eLogDebug, "NetDbReq: [:|||:]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetDbRequests::PostRequestDestination (const IdentHash& destination,
|
||||||
|
const RequestedDestination::RequestComplete& requestComplete, bool direct)
|
||||||
|
{
|
||||||
|
GetIOService ().post ([this, destination, requestComplete, direct]()
|
||||||
|
{
|
||||||
|
RequestDestination (destination, requestComplete, direct);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetDbRequests::RequestDestination (const IdentHash& destination, const RequestedDestination::RequestComplete& requestComplete, bool direct)
|
||||||
|
{
|
||||||
|
auto dest = CreateRequest (destination, false, direct, requestComplete); // non-exploratory
|
||||||
|
if (dest)
|
||||||
|
{
|
||||||
|
if (!SendNextRequest (dest))
|
||||||
|
RequestComplete (destination, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LogPrint (eLogWarning, "NetDbReq: Destination ", destination.ToBase64(), " is requested already or cached");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,12 @@ namespace data
|
|||||||
bool SendNextRequest (std::shared_ptr<RequestedDestination> dest);
|
bool SendNextRequest (std::shared_ptr<RequestedDestination> dest);
|
||||||
|
|
||||||
void PostDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
void PostDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||||
|
void PostRequestDestination (const IdentHash& destination, const RequestedDestination::RequestComplete& requestComplete, bool direct);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void HandleDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
void HandleDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||||
|
void RequestDestination (const IdentHash& destination, const RequestedDestination::RequestComplete& requestComplete, bool direct);
|
||||||
void ManageRequests ();
|
void ManageRequests ();
|
||||||
// timer
|
// timer
|
||||||
void ScheduleManageRequests ();
|
void ScheduleManageRequests ();
|
||||||
|
Loading…
Reference in New Issue
Block a user