From 43b61ff06e18a79a3e16e38445e92b0ad678bd9f Mon Sep 17 00:00:00 2001 From: Finrod Felagund Date: Mon, 3 Jun 2024 17:43:06 +0200 Subject: remove trailing whitespace and unimplemented closeSubscriptions() function --- include/nostr.hpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/nostr.hpp b/include/nostr.hpp index e5b29c7..b2cdfc5 100644 --- a/include/nostr.hpp +++ b/include/nostr.hpp @@ -164,7 +164,7 @@ public: * @brief Closes any open connections to the specified Nostr relays. */ void closeRelayConnections(std::vector relays); - + /** * @brief Publishes a Nostr event to all open relay connections. * @returns A tuple of `std::vector` objects, of the form ``, indicating @@ -206,7 +206,7 @@ public: std::function)> eventHandler, std::function eoseHandler, std::function closeHandler); - + /** * @brief Closes the subscription with the given ID on all open relay connections. * @returns A tuple of `std::vector` objects, of the form ``, indicating @@ -229,12 +229,6 @@ public: */ std::vector closeSubscriptions(); - /** - * @brief Closes all open subscriptions on the given relays. - * @returns A list of any subscription IDs that failed to close. - */ - std::vector closeSubscriptions(std::vector relays); - private: ///< The maximum number of events the service will store for each subscription. const int MAX_EVENTS_PER_SUBSCRIPTION = 128; @@ -249,7 +243,7 @@ private: ///< The default set of Nostr relays to which the service will attempt to connect. std::vector _defaultRelays; ///< The set of Nostr relays to which the service is currently connected. - std::vector _activeRelays; + std::vector _activeRelays; ///< A map from subscription IDs to the relays on which each subscription is open. std::unordered_map> _subscriptions; @@ -327,7 +321,7 @@ private: std::function)> eventHandler, std::function eoseHandler, std::function closeHandler); - + /** * @brief Parses OK messages received from the relay and invokes the given acceptance handler. * @remark The OK message type is sent to indicate whether the relay has accepted an event sent -- cgit From e6a7240c001fe8af996438ea533e58c2f1b8909a Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Thu, 8 Aug 2024 09:17:08 -0500 Subject: Fix build errors --- include/service/nostr_service_base.hpp | 4 ++-- src/service/nostr_service_base.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/service/nostr_service_base.hpp b/include/service/nostr_service_base.hpp index f1b91d1..950cf8d 100644 --- a/include/service/nostr_service_base.hpp +++ b/include/service/nostr_service_base.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -146,9 +147,8 @@ public: std::tuple, std::vector> publishEvent( std::shared_ptr event) override; - // TODO: Make this method return a promise. // TODO: Add a timeout to this method to prevent hanging while waiting for the relay. - std::vector> queryRelays( + std::future>> queryRelays( std::shared_ptr filters) override; std::string queryRelays( diff --git a/src/service/nostr_service_base.cpp b/src/service/nostr_service_base.cpp index 26748e0..a384492 100644 --- a/src/service/nostr_service_base.cpp +++ b/src/service/nostr_service_base.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include @@ -191,7 +192,7 @@ tuple, vector> NostrServiceBase::publishEvent( future>> NostrServiceBase::queryRelays( shared_ptr filters) { - return async(launch::async, [this, filters]() -> vector> + return async(launch::async, [this, filters]() -> vector> { if (filters->limit > 64 || filters->limit < 1) { @@ -199,9 +200,9 @@ future>> NostrServiceBase::queryRelays( filters->limit = 16; } - vector> events; + vector> events; - string subscriptionId = this->generateSubscriptionId(); + string subscriptionId = this->_generateSubscriptionId(); string request; try @@ -237,9 +238,9 @@ future>> NostrServiceBase::queryRelays( relay, [this, &relay, &events, &eosePromise, &uniqueEventIds](string payload) { - this->onSubscriptionMessage( + this->_onSubscriptionMessage( payload, - [&events, &uniqueEventIds](const string&, shared_ptr event) + [&events, &uniqueEventIds](const string&, shared_ptr event) { // Check if the event is unique before adding. if (uniqueEventIds.insert(event->id).second) -- cgit