From 1e6bf40d457def0faa12e3f6cf58be0e9c69e6f5 Mon Sep 17 00:00:00 2001 From: dwigton Date: Mon, 15 Jul 2024 12:05:09 -0500 Subject: Apply suggestions from code review Co-authored-by: Michael J <37635304+buttercat1791@users.noreply.github.com> --- src/nostr_service.cpp | 32 ++++++++++++++++---------------- test/nostr_service_test.cpp | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/nostr_service.cpp b/src/nostr_service.cpp index 2c1f9a8..73cd602 100644 --- a/src/nostr_service.cpp +++ b/src/nostr_service.cpp @@ -183,9 +183,9 @@ tuple, vector> NostrService::publishEvent(shared_ptr>> NostrService::queryRelays(shared_ptr filters) +future>> NostrService::queryRelays(shared_ptr filters) { - return std::async(std::launch::async, [this, filters]() -> vector> + return async(launch::async, [this, filters]() -> vector> { if (filters->limit > 64 || filters->limit < 1) { @@ -267,20 +267,20 @@ std::future>> NostrService::queryRelays(shared_ptrcloseRelayConnections({ relay }); - } - } - this->closeSubscription(subscriptionId); + for (auto& publishFuture : requestFutures) + { + auto [relay, isEose] = publishFuture.get(); + if (isEose) + { + PLOG_INFO << "Received EOSE message from relay " << relay; + } + else + { + PLOG_WARNING << "Received CLOSE message from relay " << relay; + this->closeRelayConnections({ relay }); + } + } + this->closeSubscription(subscriptionId); return events; }); diff --git a/test/nostr_service_test.cpp b/test/nostr_service_test.cpp index 6000423..d29fc87 100644 --- a/test/nostr_service_test.cpp +++ b/test/nostr_service_test.cpp @@ -772,7 +772,7 @@ TEST_F(NostrServiceTest, QueryRelays_ReturnsEvents_UpToEOSE) auto filters = make_shared(getKind0And1TestFilters()); - // await the future and get the results + // await the future and get the results auto results = nostrService->queryRelays(filters).get(); // Check results size to ensure there are no duplicates. -- cgit