class EventCache {
// TODO: remove me and change code to use ndb directly
private let ndb: Ndb
private var events: [NoteId: NostrEvent] = [:]
I thought that would be deprecated to use Ndb so I initially wrote a get_inner_event function that uses Ndb for lookup. Then I noticed the `get_inner_event()` and thought that was the standard function to be used.
Which approach would you prefer:
This also opens us up to a potentially DoS attack with many inner events
since its recursive. Ideally we do it to a depth of 1 with the cached
variant.
return nil
}
diff --git a/nostrdb/NdbNote+.swift b/nostrdb/NdbNote+.swift
index 79b2d4c7..8ea84b15 100644
--- a/nostrdb/NdbNote+.swift
+++ b/nostrdb/NdbNote+.swift
@@ -25,7 +25,14 @@ extension NdbNote {
return nil
}
-
+
+ /// Gets the inner event if this event is a repost (boost)
+ ///
+ /// DEPRECATED! please use `get_inner_event() instead`
+ ///
+ /// - Parameter cache: The Event cache to use
+ /// - Returns: The inner event, if available
+ @available(*, deprecated)
we should not be deprecating this function. we should be deprecating the
other function ...
On May 15, 2024, at 12:21, Daniel D'Aquino <dan...@daquino.me> wrote:
On May 14, 2024, at 08:05, William Casarin <jb...@jb55.com> wrote:
I see, thank you for pointing it out! I thought the one with the event_cache was the old one because of this TODO comment:class EventCache {// TODO: remove me and change code to use ndb directlyprivate let ndb: Ndbprivate var events: [NoteId: NostrEvent] = [:]I thought that would be deprecated to use Ndb so I initially wrote a get_inner_event function that uses Ndb for lookup. Then I noticed the `get_inner_event()` and thought that was the standard function to be used.Which approach would you prefer:
- Recover that new `get_inner_event(ndb: Ndb)` function and mark `ev.get_inner_event(event_cache)` as deprecated? Or,
- Use `ev.get_inner_event(event_cache)` on MutelistManager as-is?
This also opens us up to a potentially DoS attack with many inner events
since its recursive. Ideally we do it to a depth of 1 with the cached
variant.
Good point, I will implement that depth limit on the function
return nil
}
diff --git a/nostrdb/NdbNote+.swift b/nostrdb/NdbNote+.swift
index 79b2d4c7..8ea84b15 100644
--- a/nostrdb/NdbNote+.swift
+++ b/nostrdb/NdbNote+.swift
@@ -25,7 +25,14 @@ extension NdbNote {
return nil
}
-
+
+ /// Gets the inner event if this event is a repost (boost)
+ ///
+ /// DEPRECATED! please use `get_inner_event() instead`
+ ///
+ /// - Parameter cache: The Event cache to use
+ /// - Returns: The inner event, if available
+ @available(*, deprecated)
we should not be deprecating this function. we should be deprecating the
other function ...
Sounds good, I will mark the other function as deprecated
On May 24, 2024, at 15:00, Daniel D'Aquino <dan...@daquino.me> wrote:
On May 15, 2024, at 12:21, Daniel D'Aquino <dan...@daquino.me> wrote:
On May 14, 2024, at 08:05, William Casarin <jb...@jb55.com> wrote:
I see, thank you for pointing it out! I thought the one with the event_cache was the old one because of this TODO comment:class EventCache {// TODO: remove me and change code to use ndb directlyprivate let ndb: Ndbprivate var events: [NoteId: NostrEvent] = [:]I thought that would be deprecated to use Ndb so I initially wrote a get_inner_event function that uses Ndb for lookup. Then I noticed the `get_inner_event()` and thought that was the standard function to be used.Which approach would you prefer:
- Recover that new `get_inner_event(ndb: Ndb)` function and mark `ev.get_inner_event(event_cache)` as deprecated? Or,
- Use `ev.get_inner_event(event_cache)` on MutelistManager as-is?
I just noticed we cannot use event_cache in MutelistManager without substantial refactoring. The push notification extension target depends on MutelistManager. If we add the EventCache dependency, we will need to do substantial refactoring to make sure it is included on the Push notification extension target. I remember that was a rabbit hole.I will try approach 1
This also opens us up to a potentially DoS attack with many inner events
since its recursive. Ideally we do it to a depth of 1 with the cached
variant.
Good point, I will implement that depth limit on the function
return nil
}
diff --git a/nostrdb/NdbNote+.swift b/nostrdb/NdbNote+.swift
index 79b2d4c7..8ea84b15 100644
--- a/nostrdb/NdbNote+.swift
+++ b/nostrdb/NdbNote+.swift
@@ -25,7 +25,14 @@ extension NdbNote {
return nil
}
-
+
+ /// Gets the inner event if this event is a repost (boost)
+ ///
+ /// DEPRECATED! please use `get_inner_event() instead`
+ ///
+ /// - Parameter cache: The Event cache to use
+ /// - Returns: The inner event, if available
+ @available(*, deprecated)
we should not be deprecating this function. we should be deprecating the
other function ...
Sounds good, I will mark the other function as deprecated
This was added because the entire app was freezing due to the mute
changes.func get_inner_event(cache: EventCache) -> NdbNote? {
if let ev = get_cached_inner_event(cache: cache) {
return ev
base-commit: 46185c55d1dcc376842ca26e6ba47caa99a55b66
--
2.44.0