Implement timestamp-based network subscription optimization

Changelog-Changed: Optimized network bandwidth usage and improved timeline performance
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-10-13 16:56:37 -07:00
parent ab2c16288b
commit 690f8b891e
10 changed files with 591 additions and 26 deletions

View File

@@ -35,6 +35,15 @@ enum NostrConnectionEvent {
}
}
}
var subId: String? {
switch self {
case .ws_connection_event(_):
return nil
case .nostr_event(let event):
return event.subid
}
}
}
final class RelayConnection: ObservableObject {

View File

@@ -535,6 +535,8 @@ actor RelayPool {
}
for handler in handlers {
guard handler.sub_id == event.subId else { continue }
logStreamPipelineStats("RelayPool_\(relay_id.absoluteString)", "RelayPool_Handler_\(handler.sub_id)")
handler.handler.yield((relay_id, event))
}
}