mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-16 18:06:45 +00:00
c3358409bb
* Refactor of FilterV2 subscription handling and maintenance with addition subscription time-to-live support. Fixed all tests and reworked where subscription handling changes needed it. Adapted REST API /admin filter subscription retrieve to new filter subscription structure. * Fix tests and PR comments * Added filter v2 subscription timeout tests and fixed * Fix review comments and suggestions. No functional change. * Remove leftover echoes from test_rest_admin * Fix failed legacy filter tests due to separation of mounting the filters. * Small fixes, fix naming typo, removed duplicated checks in test
36 lines
865 B
Nim
36 lines
865 B
Nim
import std/tables,
|
|
stew/objects,
|
|
stew/templateutils
|
|
|
|
template keepItIf*[A, B](tableParam: var Table[A, B], itPredicate: untyped) =
|
|
bind evalTemplateParamOnce
|
|
evalTemplateParamOnce(tableParam, t):
|
|
var itemsToDelete: seq[A]
|
|
var key {.inject.} : A
|
|
var val {.inject.} : B
|
|
|
|
for k, v in t.mpairs():
|
|
key = k
|
|
val = v
|
|
if not itPredicate:
|
|
itemsToDelete.add(key)
|
|
|
|
for item in itemsToDelete:
|
|
t.del(item)
|
|
|
|
template keepItIf*[A, B](tableParam: var TableRef[A, B], itPredicate: untyped) =
|
|
bind evalTemplateParamOnce
|
|
evalTemplateParamOnce(tableParam, t):
|
|
var itemsToDelete: seq[A]
|
|
let key {.inject.} : A
|
|
let val {.inject.} : B
|
|
|
|
for k, v in t[].mpairs():
|
|
key = k
|
|
val = v
|
|
if not itPredicate:
|
|
itemsToDelete.add(key)
|
|
|
|
for item in itemsToDelete:
|
|
t[].del(item)
|