File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -277,12 +277,27 @@ proc installEthApiHandlers*(vp: VerifiedRpcProxy) =
277
277
raise newException(ValueError, error)
278
278
279
279
vp.proxy.rpc(" eth_newFilter" ) do (filterOptions: FilterOptions) -> string :
280
- var id: array [8 , byte ] # 64bits
280
+ if vp.filterStore.len >= MAX_FILTERS:
281
+ raise newException(ValueError, " FilterStore already full" )
281
282
282
- if randomBytes(id) != len(id):
283
- raise newException(ValueError, " Couldn't assign a identifier for the filter" )
283
+ var
284
+ id: array [8 , byte ] # 64bits
285
+ strId: string
284
286
285
- let strId = toHex(id)
287
+ for i in 0 .. (MAX_ID_TRIES + 1 ):
288
+ if randomBytes(id) != len(id):
289
+ raise newException(
290
+ ValueError, " Couldn't generate a random identifier for the filter"
291
+ )
292
+
293
+ strId = toHex(id)
294
+
295
+ if not vp.filterStore.contains(strId):
296
+ break
297
+
298
+ if i >= MAX_ID_TRIES:
299
+ raise
300
+ newException(ValueError, " Couldn't create a unique identifier for the filter" )
286
301
287
302
vp.filterStore[strId] =
288
303
FilterStoreItem(filter: filterOptions, blockMarker: Opt.none(Quantity))
Original file line number Diff line number Diff line change 22
22
ACCOUNTS_CACHE_SIZE = 128
23
23
CODE_CACHE_SIZE = 64
24
24
STORAGE_CACHE_SIZE = 256
25
+ MAX_ID_TRIES* = 10
26
+ MAX_FILTERS* = 256
25
27
26
28
type
27
29
AccountsCacheKey* = (Root, Address)
You can’t perform that action at this time.
0 commit comments