aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar buttercat1791 <mjjurkoic@gmail.com>2024-08-08 09:17:08 -0500
committerLibravatar buttercat1791 <mjjurkoic@gmail.com>2024-08-08 09:17:08 -0500
commite6a7240c001fe8af996438ea533e58c2f1b8909a (patch)
tree8437395768df91d2f7b6212e831e84748c89a7b8
parent5f2ac101fa951b55af699fb661866026d0998fef (diff)
Fix build errors
-rw-r--r--include/service/nostr_service_base.hpp4
-rw-r--r--src/service/nostr_service_base.cpp11
2 files changed, 8 insertions, 7 deletions
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 <functional>
+#include <future>
#include <memory>
#include <mutex>
#include <string>
@@ -146,9 +147,8 @@ public:
std::tuple<std::vector<std::string>, std::vector<std::string>> publishEvent(
std::shared_ptr<data::Event> 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<std::shared_ptr<data::Event>> queryRelays(
+ std::future<std::vector<std::shared_ptr<data::Event>>> queryRelays(
std::shared_ptr<data::Filters> 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 <future>
#include <stdexcept>
#include <thread>
+#include <unordered_set>
#include <uuid_v4.h>
@@ -191,7 +192,7 @@ tuple<vector<string>, vector<string>> NostrServiceBase::publishEvent(
future<vector<shared_ptr<nostr::data::Event>>> NostrServiceBase::queryRelays(
shared_ptr<nostr::data::Filters> filters)
{
- return async(launch::async, [this, filters]() -> vector<shared_ptr<Event>>
+ return async(launch::async, [this, filters]() -> vector<shared_ptr<nostr::data::Event>>
{
if (filters->limit > 64 || filters->limit < 1)
{
@@ -199,9 +200,9 @@ future<vector<shared_ptr<nostr::data::Event>>> NostrServiceBase::queryRelays(
filters->limit = 16;
}
- vector<shared_ptr<Event>> events;
+ vector<shared_ptr<nostr::data::Event>> events;
- string subscriptionId = this->generateSubscriptionId();
+ string subscriptionId = this->_generateSubscriptionId();
string request;
try
@@ -237,9 +238,9 @@ future<vector<shared_ptr<nostr::data::Event>>> NostrServiceBase::queryRelays(
relay,
[this, &relay, &events, &eosePromise, &uniqueEventIds](string payload)
{
- this->onSubscriptionMessage(
+ this->_onSubscriptionMessage(
payload,
- [&events, &uniqueEventIds](const string&, shared_ptr<Event> event)
+ [&events, &uniqueEventIds](const string&, shared_ptr<nostr::data::Event> event)
{
// Check if the event is unique before adding.
if (uniqueEventIds.insert(event->id).second)