diff --git a/src/itemsmanagerworker.cpp b/src/itemsmanagerworker.cpp index cbf87e65f..9c2ea3002 100644 --- a/src/itemsmanagerworker.cpp +++ b/src/itemsmanagerworker.cpp @@ -727,6 +727,7 @@ void ItemsManagerWorker::OnTabReceived(int request_id) { ++requests_completed_; + if (!error) ++total_completed_; @@ -735,16 +736,30 @@ void ItemsManagerWorker::OnTabReceived(int request_id) { if (requests_completed_ == requests_needed_) { if (cancel_update_) { updating_ = false; - } else if (queue_.size() > 0) { + } + + else if (queue_.size() > 0) { + if (cached_requests_completed_ > 0) { // We basically don't want cached requests to count against throttle limit // so if we did get any cached requests fetch up to that number without a // large delay QTimer::singleShot(1, [&]() { FetchItems(cached_requests_completed_); }); - } else { - throttled = true; - QLOG_DEBUG() << "Sleeping one minute to prevent throttling."; - QTimer::singleShot(kThrottleSleep * 1000, this, SLOT(FetchItems())); + } + + else { + ++total_pre_throttle_; + + if(total_pre_throttle_ > maxThrottleRequests) { + QLOG_DEBUG() << "Sleeping thirty minutes to prevent throttling."; + total_pre_throttle_ = 0; + QTimer::singleShot(maxThrottleSleep * 1000, this, SLOT(FetchItems())); + } else { + throttled = true; + QLOG_DEBUG() << "Sleeping one minute to prevent throttling."; + QTimer::singleShot(kThrottleSleep * 1000, this, SLOT(FetchItems())); + } + } } } diff --git a/src/itemsmanagerworker.h b/src/itemsmanagerworker.h index 6a8d178a6..48cce9f78 100644 --- a/src/itemsmanagerworker.h +++ b/src/itemsmanagerworker.h @@ -36,8 +36,11 @@ class QTimer; class BuyoutManager; class TabCache; -const int kThrottleRequests = 45; +const int kThrottleRequests = 30; const int kThrottleSleep = 60; +const int maxThrottleRequests = 4; +const int maxThrottleSleep = 1900; + const int kMaxCacheSize = (1000*1024*1024); // 1GB struct ItemsRequest { @@ -68,7 +71,7 @@ public slots: void OnFirstTabReceived(); void OnTabReceived(int index); /* - * Makes 45 requests at once, should be called every minute. + * Makes 30 requests at once, should be called every minute. * These values are approximated (GGG throttles requests) * based on some quick testing. */ @@ -105,7 +108,7 @@ public slots: std::vector > tabs_signature_; bool cancel_update_{false}; Items items_; - int total_completed_, total_needed_, total_cached_; + int total_completed_, total_needed_, total_cached_, total_pre_throttle_; int requests_completed_, requests_needed_; int cached_requests_completed_{0};