Skip to content

Commit

Permalink
check if router if real only if tunnel build rate is low and router's…
Browse files Browse the repository at this point in the history
… profile is presented when handle exploratory request
  • Loading branch information
orignal committed Apr 30, 2024
1 parent 5adbc2c commit a21bec0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libi2pd/NetDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,9 +1451,11 @@ namespace data
IdentHash destKey = CreateRoutingKey (destination);
minMetric.SetMax ();
// must be called from NetDb thread only
bool checkIsReal = i2p::tunnel::tunnels.GetPreciseTunnelCreationSuccessRate () < NETDB_TUNNEL_CREATION_RATE_THRESHOLD; // too low rate
std::lock_guard<std::mutex> l(m_RouterInfosMutex);
for (const auto& it: m_RouterInfos)
{
if (!it.second->IsDeclaredFloodfill () && it.second->GetProfile ()->IsReal ())
if (!it.second->IsDeclaredFloodfill () && (!checkIsReal || (it.second->HasProfile () && it.second->GetProfile ()->IsReal ())))
{
XORMetric m = destKey ^ it.first;
if (m < minMetric && !excluded.count (it.first))
Expand Down
1 change: 1 addition & 0 deletions libi2pd/RouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ namespace data

std::shared_ptr<RouterProfile> GetProfile () const;
void DropProfile () { m_Profile = nullptr; };
bool HasProfile () const { return (bool)m_Profile; };

bool Update (const uint8_t * buf, size_t len);
void DeleteBuffer () { m_Buffer = nullptr; };
Expand Down

0 comments on commit a21bec0

Please sign in to comment.