try to reseed again after 30 second if failed

This commit is contained in:
orignal
2026-04-26 15:17:57 -04:00
parent f618e417db
commit 52da7fe59c
2 changed files with 20 additions and 4 deletions
+17 -3
View File
@@ -75,9 +75,23 @@ namespace data
}
else // bootstrap from reseed servers
{
int num = ReseedFromServers ();
if (num == 0)
LogPrint (eLogWarning, "Reseed: Failed to reseed from servers");
auto start = i2p::util::GetMonotonicSeconds ();
int num = 0;
while (!num)
{
num = ReseedFromServers ();
if (num) break; // success
if (i2p::util::GetMonotonicSeconds () < start + RESEED_GIVEUP_TIMEOUT)
{
LogPrint (eLogWarning, "Reseed: Failed to reseed from servers. Waiting for ", RESEED_WAITING_INTERVAL, " seconds");
std::this_thread::sleep_for (std::chrono::seconds(RESEED_WAITING_INTERVAL));
}
else
break; // give up
}
if (!num)
LogPrint (eLogWarning, "Reseed: Failed to reseed from servers. Give up");
}
}
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2025, The PurpleI2P Project
* Copyright (c) 2013-2026, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@@ -22,6 +22,8 @@ namespace data
{
constexpr int MAX_NUM_RESEED_ATTEMPTS = 10;
constexpr int RESEED_CONNECT_TIMEOUT = 5; // in seconds
constexpr int RESEED_WAITING_INTERVAL = 30; // in second
constexpr int RESEED_GIVEUP_TIMEOUT = 180; // in seconds
class Reseeder
{