ton-provider-system 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1363,6 +1363,7 @@ var TokenBucketRateLimiter = class {
1363
1363
  this.config.maxBackoffMs
1364
1364
  );
1365
1365
  }
1366
+ this.tokens = 0;
1366
1367
  this.logger.warn(`Rate limit hit, backoff: ${this.currentBackoff}ms, errors: ${this.consecutiveErrors}`);
1367
1368
  }
1368
1369
  /**
@@ -1895,10 +1896,20 @@ var _ProviderManager = class _ProviderManager {
1895
1896
  this.rateLimiter = createRateLimiterManager(this.options.logger);
1896
1897
  for (const provider of this.registry.getAllProviders()) {
1897
1898
  const config2 = getRateLimitForType(provider.type);
1899
+ const minDelayMs = Math.ceil(1e3 / provider.rps * 1.1);
1900
+ let burstSize;
1901
+ if (provider.rps <= 3) {
1902
+ burstSize = 1;
1903
+ } else if (provider.rps <= 5) {
1904
+ burstSize = 2;
1905
+ } else {
1906
+ burstSize = Math.max(3, Math.ceil(provider.rps * 1.5));
1907
+ }
1898
1908
  this.rateLimiter.setConfig(provider.id, {
1899
1909
  ...config2,
1900
1910
  rps: provider.rps,
1901
- minDelayMs: Math.ceil(1e3 / provider.rps)
1911
+ minDelayMs,
1912
+ burstSize
1902
1913
  });
1903
1914
  }
1904
1915
  this.healthChecker = createHealthChecker(