Improve NostrNetworkManager interfaces

This commit improves NostrNetworkManager interfaces to be easier to use,
and with more options on how to read data from the Nostr network

This reduces the amount of duplicate logic in handling streams, and also
prevents possible common mistakes when using the standard subscribe method.

This fixes an issue with the mute list manager (which prompted for this
interface improvement, as the root cause is similar to other similar
issues).

Closes: https://github.com/damus-io/damus/issues/3221
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-09-10 13:52:39 -07:00
parent 2bea2faf3f
commit 3290e1f9d2
21 changed files with 312 additions and 296 deletions

View File

@@ -47,8 +47,8 @@ class NostrNetworkManagerTests: XCTestCase {
Task {
for await item in self.damusState!.nostrNetwork.reader.subscribe(filters: [filter]) {
switch item {
case .event(borrow: let borrow):
try? borrow { event in
case .event(let lender):
try? lender.borrow { event in
receivedCount += 1
if eventIds.contains(event.id) {
XCTFail("Got duplicate event ID: \(event.id) ")