Skip to content

Commit b9c9988

Browse files
committed
smaller request timeout if sent directly
1 parent 1bb5ad2 commit b9c9988

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

libi2pd/NetDbRequests.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013-2024, The PurpleI2P Project
2+
* Copyright (c) 2013-2025, The PurpleI2P Project
33
*
44
* This file is part of Purple i2pd project and licensed under BSD3
55
*
@@ -20,8 +20,10 @@ namespace i2p
2020
namespace data
2121
{
2222
RequestedDestination::RequestedDestination (const IdentHash& destination, bool isExploratory, bool direct):
23-
m_Destination (destination), m_IsExploratory (isExploratory), m_IsDirect (direct), m_IsActive (true),
24-
m_CreationTime (i2p::util::GetMillisecondsSinceEpoch ()), m_LastRequestTime (0), m_NumAttempts (0)
23+
m_Destination (destination), m_IsExploratory (isExploratory), m_IsDirect (direct),
24+
m_IsActive (true), m_IsSentDirectly (false),
25+
m_CreationTime (i2p::util::GetMillisecondsSinceEpoch ()),
26+
m_LastRequestTime (0), m_NumAttempts (0)
2527
{
2628
if (i2p::context.IsFloodfill ())
2729
m_ExcludedPeers.insert (i2p::context.GetIdentHash ()); // exclude self if floodfill
@@ -46,6 +48,7 @@ namespace data
4648
m_ExcludedPeers.insert (router->GetIdentHash ());
4749
m_LastRequestTime = i2p::util::GetMillisecondsSinceEpoch ();
4850
m_NumAttempts++;
51+
m_IsSentDirectly = false;
4952
return msg;
5053
}
5154

@@ -56,6 +59,7 @@ namespace data
5659
m_ExcludedPeers.insert (floodfill);
5760
m_NumAttempts++;
5861
m_LastRequestTime = i2p::util::GetMillisecondsSinceEpoch ();
62+
m_IsSentDirectly = true;
5963
return msg;
6064
}
6165

@@ -222,7 +226,8 @@ namespace data
222226
bool done = false;
223227
if (ts < dest->GetCreationTime () + MAX_REQUEST_TIME)
224228
{
225-
if (ts > dest->GetLastRequestTime () + MIN_REQUEST_TIME) // try next floodfill if no response after min interval
229+
if (ts > dest->GetLastRequestTime () + (dest->IsSentDirectly () ? MIN_DIRECT_REQUEST_TIME : MIN_REQUEST_TIME))
230+
// try next floodfill if no response after min interval
226231
done = !SendNextRequest (dest);
227232
}
228233
else // request is expired

libi2pd/NetDbRequests.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013-2024, The PurpleI2P Project
2+
* Copyright (c) 2013-2025, The PurpleI2P Project
33
*
44
* This file is part of Purple i2pd project and licensed under BSD3
55
*
@@ -28,6 +28,7 @@ namespace data
2828
const uint64_t MANAGE_REQUESTS_INTERVAL_VARIANCE = 300; // in milliseconds
2929
const uint64_t MIN_REQUEST_TIME = 1200; // in milliseconds
3030
const uint64_t MAX_REQUEST_TIME = MAX_NUM_REQUEST_ATTEMPTS * (MIN_REQUEST_TIME + MANAGE_REQUESTS_INTERVAL + MANAGE_REQUESTS_INTERVAL_VARIANCE);
31+
const uint64_t MIN_DIRECT_REQUEST_TIME = 600; // in milliseconds
3132
const uint64_t EXPLORATORY_REQUEST_INTERVAL = 55; // in seconds
3233
const uint64_t EXPLORATORY_REQUEST_INTERVAL_VARIANCE = 170; // in seconds
3334
const uint64_t DISCOVERED_REQUEST_INTERVAL = 360; // in milliseconds
@@ -52,6 +53,7 @@ namespace data
5253
bool IsExploratory () const { return m_IsExploratory; };
5354
bool IsDirect () const { return m_IsDirect; };
5455
bool IsActive () const { return m_IsActive; };
56+
bool IsSentDirectly () const { return m_IsSentDirectly; };
5557
bool IsExcluded (const IdentHash& ident) const;
5658
uint64_t GetCreationTime () const { return m_CreationTime; };
5759
uint64_t GetLastRequestTime () const { return m_LastRequestTime; };
@@ -70,7 +72,7 @@ namespace data
7072
private:
7173

7274
IdentHash m_Destination;
73-
bool m_IsExploratory, m_IsDirect, m_IsActive;
75+
bool m_IsExploratory, m_IsDirect, m_IsActive, m_IsSentDirectly;
7476
std::unordered_set<IdentHash> m_ExcludedPeers;
7577
uint64_t m_CreationTime, m_LastRequestTime; // in milliseconds
7678
std::list<RequestComplete> m_RequestComplete;

0 commit comments

Comments
 (0)