mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 22:43:09 +00:00
add more temporary debug logs
This commit is contained in:
parent
a4febc88a7
commit
610b4f9e86
@ -31,7 +31,7 @@ type WakuFilter* = ref object of LPProtocol
|
||||
peerConnections: Table[PeerId, Connection]
|
||||
|
||||
proc pingSubscriber(wf: WakuFilter, peerId: PeerID): FilterSubscribeResult =
|
||||
debug "pinging subscriber", peerId = peerId
|
||||
debug "AAAAAAA pinging subscriber", peerId = peerId
|
||||
|
||||
if not wf.subscriptions.isSubscribed(peerId):
|
||||
error "pinging peer has no subscriptions", peerId = peerId
|
||||
|
||||
@ -51,7 +51,17 @@ proc new*(
|
||||
|
||||
proc isSubscribed*(s: FilterSubscriptions, peerId: PeerID): bool =
|
||||
s.peersSubscribed.withValue(peerId, data):
|
||||
return Moment.now() - data.lastSeen <= s.subscriptionTimeout
|
||||
let now = Moment.now()
|
||||
let diffTime = now - data.lastSeen
|
||||
|
||||
debug "AAAAAAA isSubscribed",
|
||||
peerId,
|
||||
now = $now,
|
||||
lastSeen = $data.lastSeen,
|
||||
diffTime = $diffTime,
|
||||
subscrTimeout = $s.subscriptionTimeout
|
||||
|
||||
return diffTime <= s.subscriptionTimeout
|
||||
|
||||
return false
|
||||
|
||||
@ -133,8 +143,10 @@ proc cleanUp*(fs: FilterSubscriptions) =
|
||||
currentPeerIds = toSeq(fs.peersSubscribed.keys).mapIt(shortLog(it))
|
||||
|
||||
proc refreshSubscription*(s: var FilterSubscriptions, peerId: PeerID) =
|
||||
debug "AAAAAAA refreshSubscription"
|
||||
s.peersSubscribed.withValue(peerId, data):
|
||||
data.lastSeen = Moment.now()
|
||||
debug "AAAAAAA refreshSubscription", peerId, lastSeen = data.lastSeen
|
||||
|
||||
proc addSubscription*(
|
||||
s: FilterSubscriptions, peerId: PeerID, filterCriteria: FilterCriteria
|
||||
@ -153,7 +165,8 @@ proc addSubscription*(
|
||||
debug "AAAAAAA peer already subscribed",
|
||||
peerID = shortLog(peerId),
|
||||
criteriaCount = data.criteriaCount,
|
||||
maxCriteriaPerPeer = s.maxCriteriaPerPeer
|
||||
maxCriteriaPerPeer = s.maxCriteriaPerPeer,
|
||||
lastSeen = data.lastSeen
|
||||
|
||||
peerData = data
|
||||
do:
|
||||
@ -163,7 +176,9 @@ proc addSubscription*(
|
||||
peerID = shortLog(peerId), maxPeers = $(s.maxPeers)
|
||||
return err("node has reached maximum number of subscriptions: " & $(s.maxPeers))
|
||||
|
||||
let newPeerData: PeerData = (lastSeen: Moment.now(), criteriaCount: 0)
|
||||
let now = Moment.now()
|
||||
debug "AAAAAAA adding new peer", peerId, lastSeen = now
|
||||
let newPeerData: PeerData = (lastSeen: now, criteriaCount: 0)
|
||||
peerData = addr(s.peersSubscribed.mgetOrPut(peerId, newPeerData))
|
||||
|
||||
for filterCriterion in filterCriteria:
|
||||
@ -187,7 +202,9 @@ proc removeSubscription*(
|
||||
debug "AAAAAAA removeSubscription", peerId = shortLog(peerID)
|
||||
|
||||
s.peersSubscribed.withValue(peerId, peerData):
|
||||
peerData.lastSeen = Moment.now()
|
||||
let now = Moment.now()
|
||||
debug "AAAAAAA refresh lastSeen", peerId, now
|
||||
peerData.lastSeen = now
|
||||
for filterCriterion in filterCriteria:
|
||||
s.subscriptions.withValue(filterCriterion, peers):
|
||||
if peers[].missingOrexcl(peerId) == false:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user