perf: improve filter generation performance

for some reason the filter here was taking ~6ms to create...

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-09-30 18:05:12 -04:00
parent 810b4c1990
commit af53dd4852
2 changed files with 11 additions and 3 deletions

View File

@@ -626,11 +626,15 @@ impl TimelineKind {
pub fn notifications_filter(pk: &Pubkey) -> Filter {
Filter::new()
.pubkeys([pk.bytes()])
.kinds([1, 7, 6])
.kinds(notification_kinds())
.limit(default_limit())
.build()
}
pub fn notification_kinds() -> [u64; 3] {
[1, 7, 6]
}
#[derive(Debug)]
pub struct TitleNeedsDb<'a> {
kind: &'a TimelineKind,

View File

@@ -25,8 +25,12 @@ pub fn unseen_notification(
profiling::scope!("NotesFreshness::update closure");
let filter = {
profiling::scope!("NotesFreshness::update filter instantiation");
crate::timeline::kind::notifications_filter(&current_pk)
.since_mut(timestamp_last_viewed)
enostr::Filter::new_with_capacity(1)
.pubkeys([current_pk.bytes()])
.kinds(crate::timeline::kind::notification_kinds())
.limit(1)
.since(timestamp_last_viewed)
.build()
};
let txn = Transaction::new(ndb).expect("txn");