1
0
mirror of git://jb55.com/damus synced 2024-09-29 08:20:45 +00:00
damus/nostrdb/NdbNote+.swift
William Casarin 909701ce7b profile: partially fix performance regression
This will be completely fixed once we switch to stored note blocks
2024-01-10 11:52:30 -08:00

36 lines
862 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// NdbNote+.swift
// damus
//
// Created by Daniel DAquino on 2023-11-17.
//
import Foundation
// Extension to make NdbNote compatible with NostrEvent's original API
extension NdbNote {
func parse_inner_event() -> NdbNote? {
return NdbNote.owned_from_json_cstr(json: content_raw, json_len: content_len)
}
func get_cached_inner_event(cache: EventCache) -> NdbNote? {
guard self.known_kind == .boost else {
return nil
}
if self.content_len == 0, let id = self.referenced_ids.first {
// TODO: raw id cache lookups
return cache.lookup(id)
}
return nil
}
func get_inner_event(cache: EventCache) -> NdbNote? {
if let ev = get_cached_inner_event(cache: cache) {
return ev
}
return self.parse_inner_event()
}
}