mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-18 16:49:58 +00: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)
|
||||
{
|
||||
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 (dest)
|
||||
{
|
||||
if (!m_Requests->SendNextRequest (dest))
|
||||
m_Requests->RequestComplete (destination, nullptr);
|
||||
}
|
||||
if (m_Requests)
|
||||
m_Requests->PostRequestDestination (destination, requestComplete, direct);
|
||||
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)
|
||||
|
@ -405,7 +405,7 @@ namespace data
|
||||
/* if(m_FloodfillBootstrap)
|
||||
RequestDestinationFrom(router, m_FloodfillBootstrap->GetIdentHash(), true);
|
||||
else */if (!IsRouterBanned (router))
|
||||
netdb.RequestDestination (router);
|
||||
RequestDestination (router, nullptr, true);
|
||||
else
|
||||
LogPrint (eLogDebug, "NetDbReq: Router ", peerHash, " is banned. Skipped");
|
||||
}
|
||||
@ -413,5 +413,26 @@ namespace data
|
||||
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);
|
||||
|
||||
void PostDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
void PostRequestDestination (const IdentHash& destination, const RequestedDestination::RequestComplete& requestComplete, bool direct);
|
||||
|
||||
private:
|
||||
|
||||
void HandleDatabaseSearchReplyMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
void RequestDestination (const IdentHash& destination, const RequestedDestination::RequestComplete& requestComplete, bool direct);
|
||||
void ManageRequests ();
|
||||
// timer
|
||||
void ScheduleManageRequests ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user