From b9931e277d13cfee961fdb1af205e7920a2ab65c Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Thu, 5 Dec 2024 20:30:38 +0100 Subject: [PATCH] filter: some adjustments to avoid crash and use new insteat init --- waku/waku_filter_v2/protocol.nim | 2 +- waku/waku_filter_v2/subscriptions.nim | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/waku/waku_filter_v2/protocol.nim b/waku/waku_filter_v2/protocol.nim index 7eb0688ac..cc49e1263 100644 --- a/waku/waku_filter_v2/protocol.nim +++ b/waku/waku_filter_v2/protocol.nim @@ -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, diff --git a/waku/waku_filter_v2/subscriptions.nim b/waku/waku_filter_v2/subscriptions.nim index eb0ffff98..abb413c5a 100644 --- a/waku/waku_filter_v2/subscriptions.nim +++ b/waku/waku_filter_v2/subscriptions.nim @@ -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[]: