diff options
author | dwigton <daniel@stonecottageweb.com> | 2024-07-15 12:05:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 12:05:09 -0500 |
commit | 1e6bf40d457def0faa12e3f6cf58be0e9c69e6f5 (patch) | |
tree | 041ea8ca06a26fb6a25bcb30c9964cbceed69e74 | |
parent | 9cbe27d3e5e15a3790cc9d5d3e9cc5852ce08df4 (diff) |
Apply suggestions from code review
Co-authored-by: Michael J <37635304+buttercat1791@users.noreply.github.com>
-rw-r--r-- | src/nostr_service.cpp | 32 | ||||
-rw-r--r-- | 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<string>, vector<string>> NostrService::publishEvent(shared_ptr<Even }; // TODO: Add a timeout to this method to prevent hanging while waiting for the relay. -std::future<vector<shared_ptr<Event>>> NostrService::queryRelays(shared_ptr<Filters> filters) +future<vector<shared_ptr<Event>>> NostrService::queryRelays(shared_ptr<Filters> filters) { - return std::async(std::launch::async, [this, filters]() -> vector<shared_ptr<Event>> + return async(launch::async, [this, filters]() -> vector<shared_ptr<Event>> { if (filters->limit > 64 || filters->limit < 1) { @@ -267,20 +267,20 @@ std::future<vector<shared_ptr<Event>>> NostrService::queryRelays(shared_ptr<Filt // Close open subscriptions and disconnect from relays after events are received. - 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); + 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<nostr::Filters>(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. |