Fixed bugs on API key pool

This commit is contained in:
jim
2026-05-03 13:59:51 -05:00
parent 6cec7afb53
commit 34e5745e99
2 changed files with 45 additions and 10 deletions
+22
View File
@@ -1773,6 +1773,28 @@ namespace URLNotesGrabberCORE
cmd.ExecuteNonQuery();
}
public static bool IsAllRateLimited(out int minRetrySeconds)
{
minRetrySeconds = 0;
if (!_usePool || _overrideKey != null) return false;
if (_keys.Count <= 1) return true;
var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
bool all = true;
int min = int.MaxValue;
foreach (var key in _keys)
{
var retryUntil = GetRetryUntil(key);
if (retryUntil <= now) { all = false; break; }
int remaining = (int)(retryUntil - now);
if (remaining < min) min = remaining;
}
minRetrySeconds = all ? min : 0;
return all;
}
private static void SaveState()
{
using var conn = new System.Data.SQLite.SQLiteConnection("Data Source=" + _dbPath);