filter: some adjustments to avoid crash and use new insteat init

This commit is contained in:
Ivan Folgueira Bande 2024-12-05 20:30:38 +01:00
parent 26a2112c5d
commit b9931e277d
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
2 changed files with 4 additions and 2 deletions

View File

@ -330,7 +330,7 @@ proc new*(
rateLimitSetting: Option[RateLimitSetting] = none[RateLimitSetting](),
): T =
let wf = WakuFilter(
subscriptions: FilterSubscriptions.init(
subscriptions: FilterSubscriptions.new(
subscriptionTimeout, maxFilterPeers, maxFilterCriteriaPerPeer
),
peerManager: peerManager,

View File

@ -40,7 +40,7 @@ type
maxPeers: uint
maxCriteriaPerPeer: uint
proc init*(
proc new*(
T: type FilterSubscriptions,
subscriptionTimeout: Duration = DefaultSubscriptionTimeToLiveSec,
maxFilterPeers: uint32 = MaxFilterPeers,
@ -172,6 +172,8 @@ proc addSubscription*(
let newPeerData: PeerData =
(lastSeen: Moment.now(), criteriaCount: 0, connection: connRes.get())
peerData = addr(s.peersSubscribed.mgetOrPut(peerId, newPeerData))
for filterCriterion in filterCriteria:
var peersOfSub = addr(s.subscriptions.mgetOrPut(filterCriterion, SubscribedPeers()))
if peerId notin peersOfSub[]: