Integrate Negentropy with Subscription Manager

This makes negentropy optimizations available to the rest of the app via
Subscription Manager.

Changelog not needed because this should not have user-facing changes

Changelog-None
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2026-01-16 17:12:49 -08:00
parent 95d38fa802
commit d8f4dbb2aa
9 changed files with 698 additions and 106 deletions

View File

@@ -36,4 +36,22 @@ extension Ndb {
func processEvent(_ str: String, originRelayURL: RelayURL? = nil) -> Bool {
self.process_event(str, originRelayURL: originRelayURL?.absoluteString)
}
/// Adds a NostrEvent to the database by converting it to a push event and processing it.
/// - Parameter event: The NostrEvent to add
/// - Throws: NdbAddError.couldNotMakePushEvent if the event cannot be converted, or NdbAddError.processingFailed if processing fails
func add(event: NostrEvent) throws {
guard let nostrPushEvent = make_nostr_push_event(ev: event) else {
throw NdbAddError.couldNotMakePushEvent
}
let success = self.process_client_event(nostrPushEvent)
if !success {
throw NdbAddError.processingFailed
}
}
enum NdbAddError: Error {
case couldNotMakePushEvent
case processingFailed
}
}