fetch following contacts if we are missing any

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-05-24 15:29:28 -07:00
parent 8aac880bb5
commit dbf8c932ae
7 changed files with 136 additions and 29 deletions

View File

@@ -18,6 +18,26 @@ func insert_uniq<T: Equatable>(xs: inout [T], new_x: T) -> Bool {
return true
}
func insert_uniq_by_pubkey(events: inout [NostrEvent], new_ev: NostrEvent, cmp: (NostrEvent, NostrEvent) -> Bool) -> Bool {
var i: Int = 0
for event in events {
// don't insert duplicate events
if new_ev.pubkey == event.pubkey {
return false
}
if cmp(new_ev, event) {
events.insert(new_ev, at: i)
return true
}
i += 1
}
events.append(new_ev)
return true
}
func insert_uniq_sorted_event(events: inout [NostrEvent], new_ev: NostrEvent, cmp: (NostrEvent, NostrEvent) -> Bool) -> Bool {
var i: Int = 0