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.cjs CHANGED
@@ -1366,6 +1366,7 @@ var TokenBucketRateLimiter = class {
1366
1366
  this.config.maxBackoffMs
1367
1367
  );
1368
1368
  }
1369
+ this.tokens = 0;
1369
1370
  this.logger.warn(`Rate limit hit, backoff: ${this.currentBackoff}ms, errors: ${this.consecutiveErrors}`);
1370
1371
  }
1371
1372
  /**
@@ -1898,10 +1899,20 @@ var _ProviderManager = class _ProviderManager {
1898
1899
  this.rateLimiter = createRateLimiterManager(this.options.logger);
1899
1900
  for (const provider of this.registry.getAllProviders()) {
1900
1901
  const config2 = getRateLimitForType(provider.type);
1902
+ const minDelayMs = Math.ceil(1e3 / provider.rps * 1.1);
1903
+ let burstSize;
1904
+ if (provider.rps <= 3) {
1905
+ burstSize = 1;
1906
+ } else if (provider.rps <= 5) {
1907
+ burstSize = 2;
1908
+ } else {
1909
+ burstSize = Math.max(3, Math.ceil(provider.rps * 1.5));
1910
+ }
1901
1911
  this.rateLimiter.setConfig(provider.id, {
1902
1912
  ...config2,
1903
1913
  rps: provider.rps,
1904
- minDelayMs: Math.ceil(1e3 / provider.rps)
1914
+ minDelayMs,
1915
+ burstSize
1905
1916
  });
1906
1917
  }
1907
1918
  this.healthChecker = createHealthChecker(