diff options
author | Michael Jurkoic <mjjurkoic@gmail.com> | 2024-03-17 14:36:41 -0500 |
---|---|---|
committer | Michael Jurkoic <mjjurkoic@gmail.com> | 2024-03-17 14:36:41 -0500 |
commit | 423536e49259d338499dd8f8afaf106be7360764 (patch) | |
tree | 3a8dcbf74c792f2e6e3c67b43164370f24f6cba1 /include/nostr.hpp | |
parent | 20b0f9c073d52e95b02399d6a243010e36b6c4f1 (diff) |
Open relay subscriptions for a filter request
Diffstat (limited to 'include/nostr.hpp')
-rw-r--r-- | include/nostr.hpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/nostr.hpp b/include/nostr.hpp index 8041efe..22d9956 100644 --- a/include/nostr.hpp +++ b/include/nostr.hpp @@ -142,12 +142,22 @@ public: */ std::tuple<RelayList, RelayList> publishEvent(Event event); - // TODO: Add methods for reading events from relays. + /** + * @brief Queries all open relay connections for events matching the given set of filters. + * @returns A tuple of `RelayList` objects, of the form `<successes, failures>`, indicating + * to which relays the request was successfully sent, and which relays did not successfully + * receive the request. + */ + std::tuple<RelayList, RelayList> queryRelays(Filters filters); + + // TODO: Write a method that receives events for an active subscription. + // TODO: Write a method that closes active subscriptions. private: std::mutex _propertyMutex; RelayList _defaultRelays; RelayList _activeRelays; + std::unordered_map<std::string, std::vector<std::string>> _subscriptionIds; client::IWebSocketClient* _client; /** @@ -182,5 +192,11 @@ private: * @brief Closes the connection from the client to the given relay. */ void disconnect(std::string relay); + + /** + * @brief Generates a unique subscription ID that may be used to identify event requests. + * @returns A stringified UUID. + */ + std::string generateSubscriptionId(); }; } // namespace nostr |