Skip to content

Commit

Permalink
Make heavy request limits configurable and enhance logging (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
S0naliThakur authored Dec 30, 2024
1 parent 2318f60 commit c2420d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,9 @@ export class RequestersList {
this.addHeavyRequest(ip)
const heavyReqHistory = this.heavyRequests.get(ip)

if (heavyReqHistory && heavyReqHistory.length >= 61) {
if (now - heavyReqHistory[heavyReqHistory.length - 61] < oneMinute) {
if (verbose) console.log(`Ban this ip ${ip} due to continuously sending more than 60 reqs in 60s`)
if (heavyReqHistory && heavyReqHistory.length >= config.rateLimitOption.allowedHeavyRequestPerMin + 1) {
if (now - heavyReqHistory[heavyReqHistory.length - config.rateLimitOption.allowedHeavyRequestPerMin] < oneMinute) {
if (verbose) console.log(`Ban this ip ${ip} due to continuously sending more than ${config.rateLimitOption.allowedHeavyRequestPerMin} reqs in 60s`)
this.addToBlacklist(ip)
if (config.recordTxStatus && reqType === 'eth_sendRawTransaction') {
const transaction = getTransactionObj({ raw: reqParams[0] })
Expand Down

0 comments on commit c2420d4

Please sign in to comment.