ton-provider-system 0.1.4 → 0.1.6

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
@@ -1318,6 +1318,8 @@ var TokenBucketRateLimiter = class {
1318
1318
  if (this.currentBackoff > 0) {
1319
1319
  this.logger.debug(`Applying backoff: ${this.currentBackoff}ms`);
1320
1320
  await sleep(this.currentBackoff);
1321
+ this.lastRefill = Date.now();
1322
+ this.currentBackoff = 0;
1321
1323
  }
1322
1324
  while (this.tokens <= 0) {
1323
1325
  if (Date.now() - startTime > timeoutMs) {
@@ -1367,6 +1369,7 @@ var TokenBucketRateLimiter = class {
1367
1369
  );
1368
1370
  }
1369
1371
  this.tokens = 0;
1372
+ this.lastRefill = Date.now();
1370
1373
  this.logger.warn(`Rate limit hit, backoff: ${this.currentBackoff}ms, errors: ${this.consecutiveErrors}`);
1371
1374
  }
1372
1375
  /**
@@ -1899,7 +1902,8 @@ var _ProviderManager = class _ProviderManager {
1899
1902
  this.rateLimiter = createRateLimiterManager(this.options.logger);
1900
1903
  for (const provider of this.registry.getAllProviders()) {
1901
1904
  const config2 = getRateLimitForType(provider.type);
1902
- const minDelayMs = Math.ceil(1e3 / provider.rps * 1.1);
1905
+ const bufferMultiplier = provider.rps <= 3 ? 1.2 : 1.1;
1906
+ const minDelayMs = Math.ceil(1e3 / provider.rps * bufferMultiplier);
1903
1907
  let burstSize;
1904
1908
  if (provider.rps <= 3) {
1905
1909
  burstSize = 1;