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

@@ -34,6 +34,7 @@ struct DamusState {
let user_search_cache: UserSearchCache
let music: MusicController?
let video: VideoController
let ndb: Ndb
@discardableResult
func add_zap(zap: Zapping) -> Bool {
@@ -67,12 +68,12 @@ struct DamusState {
let kp = Keypair(pubkey: empty_pub, privkey: nil)
return DamusState.init(
pool: RelayPool(),
pool: RelayPool(ndb: .empty),
keypair: Keypair(pubkey: empty_pub, privkey: empty_sec),
likes: EventCounter(our_pubkey: empty_pub),
boosts: EventCounter(our_pubkey: empty_pub),
contacts: Contacts(our_pubkey: empty_pub),
profiles: Profiles(user_search_cache: user_search_cache),
profiles: Profiles(user_search_cache: user_search_cache, ndb: .empty),
dms: DirectMessagesModel(our_pubkey: empty_pub),
previews: PreviewCache(),
zaps: Zaps(our_pubkey: empty_pub),
@@ -81,9 +82,9 @@ struct DamusState {
relay_filters: RelayFilters(our_pubkey: empty_pub),
relay_model_cache: RelayModelCache(),
drafts: Drafts(),
events: EventCache(),
events: EventCache(ndb: .empty),
bookmarks: BookmarksManager(pubkey: empty_pub),
postbox: PostBox(pool: RelayPool()),
postbox: PostBox(pool: RelayPool(ndb: .empty)),
bootstrap_relays: [],
replies: ReplyCounter(our_pubkey: empty_pub),
muted_threads: MutedThreadsManager(keypair: kp),
@@ -91,7 +92,8 @@ struct DamusState {
nav: NavigationCoordinator(),
user_search_cache: user_search_cache,
music: nil,
video: VideoController()
video: VideoController(),
ndb: .empty
)
}
}