Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] SHARD-893: Clear filtersMap when it reaches maximum entries allowed #85

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,10 @@ export const methods = {
unsubscribe,
type: Types.FilterTypes.block,
}
if (filtersMap.size >= config.maxEntriesAllowed) {
filtersMap.clear()
console.log(`filtersMap cleared after ${config.maxEntriesAllowed} entries`)
}
filtersMap.set(filterId.toString(), internalFilter)

callback(null, filterId)
Expand Down Expand Up @@ -2819,6 +2823,10 @@ export const methods = {
unsubscribe,
type: Types.FilterTypes.pendingTransaction,
}
if (filtersMap.size >= config.maxEntriesAllowed) {
filtersMap.clear()
console.log(`filtersMap cleared after ${config.maxEntriesAllowed} entries`)
}
filtersMap.set(filterId.toString(), internalFilter)

callback(null, filterId)
Expand Down Expand Up @@ -2920,6 +2928,10 @@ export const methods = {
unsubscribe,
type: Types.FilterTypes.log,
}
if (filtersMap.size >= config.maxEntriesAllowed) {
filtersMap.clear()
console.log(`filtersMap cleared after ${config.maxEntriesAllowed} entries`)
}
filtersMap.set(filterId.toString(), internalFilter)

callback(null, filterId)
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type Config = {
}
axiosTimeoutInMs: number
enableBlacklistingIP: boolean
maxEntriesAllowed: number // maximum number of entries allowed for map to store
}

export type ServicePointTypes = 'aalg-warmup'
Expand Down Expand Up @@ -249,4 +250,5 @@ export const CONFIG: Config = {
},
axiosTimeoutInMs: 3000,
enableBlacklistingIP: false,
maxEntriesAllowed: 10000,
}
Loading