mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-18 19:23:40 +00:00
optimize deduplication.
This commit is contained in:
parent
1188dc55be
commit
1e270b52aa
@ -263,17 +263,20 @@ const subscribe = async (
|
||||
return
|
||||
}
|
||||
|
||||
const sub = conn.nostr.sub(filter, {id})
|
||||
const sub = conn.nostr.sub(filter, {
|
||||
id,
|
||||
alreadyHaveEvent: (id) => {
|
||||
conn.stats.eventsCount += 1
|
||||
let has = false
|
||||
if (seen.has(id)) has = true
|
||||
seen.add(id)
|
||||
return has
|
||||
}
|
||||
})
|
||||
|
||||
sub.on('event', e => {
|
||||
conn.stats.eventsCount += 1
|
||||
|
||||
if (!seen.has(e.id)) {
|
||||
seen.add(e.id)
|
||||
|
||||
// Normalize events here, annotate with relay url
|
||||
onEvent({...e, seen_on: relay.url, content: e.content || ''})
|
||||
}
|
||||
})
|
||||
|
||||
sub.on('eose', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user