nomagick commited on
Commit
4498af7
·
unverified ·
1 Parent(s): 0238d26

fix: try to partition apiroll query

Browse files
Files changed (2) hide show
  1. src/api/crawler.ts +3 -3
  2. thinapps-shared +1 -1
src/api/crawler.ts CHANGED
@@ -258,7 +258,7 @@ export class CrawlerHost extends RPCHost {
258
  throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`);
259
  }
260
 
261
- const rateLimitPolicy = auth.getRateLimits(rpcReflect.name.toUpperCase()) || [
262
  parseInt(user.metadata?.speed_level) >= 2 ?
263
  RateLimitDesc.from({
264
  occurrence: 2000,
@@ -271,7 +271,7 @@ export class CrawlerHost extends RPCHost {
271
  ];
272
 
273
  const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit(
274
- rpcReflect, uid, [rpcReflect.name.toUpperCase()],
275
  ...rateLimitPolicy
276
  );
277
 
@@ -287,7 +287,7 @@ export class CrawlerHost extends RPCHost {
287
  }
288
  });
289
  } else if (ctx.ip) {
290
- const apiRoll = await this.rateLimitControl.simpleRpcIPBasedLimit(rpcReflect, ctx.ip, [rpcReflect.name.toUpperCase()],
291
  [
292
  // 20 requests per minute
293
  new Date(Date.now() - 60 * 1000), 20
 
258
  throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`);
259
  }
260
 
261
+ const rateLimitPolicy = auth.getRateLimits('CRAWL') || [
262
  parseInt(user.metadata?.speed_level) >= 2 ?
263
  RateLimitDesc.from({
264
  occurrence: 2000,
 
271
  ];
272
 
273
  const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit(
274
+ rpcReflect, uid, ['CRAWL'],
275
  ...rateLimitPolicy
276
  );
277
 
 
287
  }
288
  });
289
  } else if (ctx.ip) {
290
+ const apiRoll = await this.rateLimitControl.simpleRpcIPBasedLimit(rpcReflect, ctx.ip, ['CRAWL'],
291
  [
292
  // 20 requests per minute
293
  new Date(Date.now() - 60 * 1000), 20
thinapps-shared CHANGED
@@ -1 +1 @@
1
- Subproject commit 492ed4cac38958c3715013da49a9e73b1d1ef8cb
 
1
+ Subproject commit 9a04a66d10635bd4e5f46123fc2b59ec802bf3b7