From 4b66a41aff99ef5f7c72f46171dbdf6605c240b4 Mon Sep 17 00:00:00 2001 From: Finrod Felagund Date: Mon, 15 Apr 2024 22:26:34 +0200 Subject: use uuid_v4 to generate faster UUIDs than Boost --- src/nostr_service.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/nostr_service.cpp') diff --git a/src/nostr_service.cpp b/src/nostr_service.cpp index 3dbff62..3a59fa6 100644 --- a/src/nostr_service.cpp +++ b/src/nostr_service.cpp @@ -1,19 +1,15 @@ #include -#include -#include -#include + #include #include #include #include #include +#include #include "nostr.hpp" #include "client/web_socket_client.hpp" -using boost::uuids::random_generator; -using boost::uuids::to_string; -using boost::uuids::uuid; using nlohmann::json; using std::async; using std::exception; @@ -49,7 +45,7 @@ NostrService::NostrService( shared_ptr signer, RelayList relays) : _defaultRelays(relays), _client(client), _signer(signer) -{ +{ plog::init(plog::debug, appender.get()); client->start(); }; @@ -178,7 +174,7 @@ tuple NostrService::publishEvent(shared_ptr event) } }); }); - + if (!success) { PLOG_WARNING << "Failed to send event to relay: " << relay; @@ -288,7 +284,7 @@ string NostrService::queryRelays( for (const string relay : this->_activeRelays) { this->_subscriptions[relay].push_back(subscriptionId); - + promise> requestPromise; requestFutures.push_back(move(requestPromise.get_future())); future> requestFuture = async( @@ -517,8 +513,9 @@ void NostrService::disconnect(string relay) string NostrService::generateSubscriptionId() { - uuid uuid = random_generator()(); - return to_string(uuid); + UUIDv4::UUIDGenerator uuidGenerator; + UUIDv4::UUID uuid = uuidGenerator.getUUID(); + return uuid.bytes(); }; string NostrService::generateCloseRequest(string subscriptionId) -- cgit