mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-19 19:46:42 +00:00
optimize deduplication.
This commit is contained in:
parent
91df2e2247
commit
2e99b74b79
@ -263,17 +263,20 @@ const subscribe = async (
|
|||||||
return
|
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 => {
|
sub.on('event', e => {
|
||||||
conn.stats.eventsCount += 1
|
|
||||||
|
|
||||||
if (!seen.has(e.id)) {
|
|
||||||
seen.add(e.id)
|
|
||||||
|
|
||||||
// Normalize events here, annotate with relay url
|
// Normalize events here, annotate with relay url
|
||||||
onEvent({...e, seen_on: relay.url, content: e.content || ''})
|
onEvent({...e, seen_on: relay.url, content: e.content || ''})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
sub.on('eose', () => {
|
sub.on('eose', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user