Extract RelayPool seen-note recording
Move the shared seen, count, and notification update into a note-id helper. This commit does not change behavior. Signed-off-by: Sjors Provoost <sjors@sprovoost.nl>
This commit is contained in:
@@ -734,15 +734,21 @@ class RelayPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Records that a relay is known to have accepted or returned a note.
|
||||||
|
func record_seen(relay_id: RelayURL, note_id: NoteId) {
|
||||||
|
if seen[note_id]?.contains(relay_id) == true {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
seen[note_id, default: Set()].insert(relay_id)
|
||||||
|
counts[relay_id, default: 0] += 1
|
||||||
|
notify(.update_stats(note_id: note_id))
|
||||||
|
}
|
||||||
|
|
||||||
func record_seen(relay_id: RelayURL, event: NostrConnectionEvent) {
|
func record_seen(relay_id: RelayURL, event: NostrConnectionEvent) {
|
||||||
if case .nostr_event(let ev) = event {
|
if case .nostr_event(let ev) = event {
|
||||||
if case .event(_, let nev) = ev {
|
if case .event(_, let nev) = ev {
|
||||||
if seen[nev.id]?.contains(relay_id) == true {
|
record_seen(relay_id: relay_id, note_id: nev.id)
|
||||||
return
|
|
||||||
}
|
|
||||||
seen[nev.id, default: Set()].insert(relay_id)
|
|
||||||
counts[relay_id, default: 0] += 1
|
|
||||||
notify(.update_stats(note_id: nev.id))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user