nostrdb: add profiles to nostrdb

This adds profiles to nostrdb

- Remove in-memory Profiles caches, nostrdb is as fast as an in-memory cache
- Remove ProfileDatabase and just use nostrdb directly

Changelog-Changed: Use nostrdb for profiles
This commit is contained in:
William Casarin
2023-08-28 07:52:59 -07:00
parent 8586eed635
commit bb4fd75576
42 changed files with 362 additions and 705 deletions

View File

@@ -137,6 +137,7 @@ class EventData {
}
class EventCache {
private let ndb: Ndb
private var events: [NoteId: NostrEvent] = [:]
private var replies = ReplyMap()
private var cancellable: AnyCancellable?
@@ -145,7 +146,8 @@ class EventCache {
//private var thread_latest: [String: Int64]
init() {
init(ndb: Ndb) {
self.ndb = ndb
cancellable = NotificationCenter.default.publisher(
for: UIApplication.didReceiveMemoryWarningNotification
).sink { [weak self] _ in
@@ -250,7 +252,11 @@ class EventCache {
insert(ev)
return ev
}
func lookup_by_key(_ key: UInt64) -> NostrEvent? {
ndb.lookup_note_by_key(key)
}
func lookup(_ evid: NoteId) -> NostrEvent? {
return events[evid]
}