-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nostr Client #2
base: master
Are you sure you want to change the base?
Nostr Client #2
Conversation
uWebSockets doesn't provide client support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First feedback.
Also include nostr.hpp in gitrepublic.h and ensure the whole project builds successfully.
- Set up the nostr namespace as a library named gitrepublic-ndk. - Add GTest to the project. - Fix build errors.
- Rename NostrUtils -> NostrService - Define interface IWebSocketClient - NostrService only interacts with WebSocket protocol via the IWebSocketClient interface - NostrService accepts a client instance in its constructor - Create an IWebSocketClient implementation based on WebSocket++
- Create a mock implementation of IWebSocket client to use in unit tests for the NostrService class. - Fetch and build Google Test via CMake to ensure it uses the same compiler settings and targets as the project it is testing.
// Configure the connection here via the connection pointer. | ||
connection->set_fail_handler([this, uri](auto handle) { | ||
// PLOG_ERROR << "Error connecting to relay " << relay << ": Handshake failed."; | ||
lock_guard<mutex> lock(this->_propertyMutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isConnected also locks the mutex - I assume it works, but the lock_guard could be placed inside the if
for (string relay : unconnectedRelays) | ||
{ | ||
thread connectionThread([this, relay]() { | ||
this->connect(relay); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this fails? Not sure if that's possible or already covered in the function itself.
|
||
void Event::deserialize(string jsonString) | ||
{ | ||
nlohmann::json j = nlohmann::json::parse(jsonString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think .at() would be more safe than the index (even if it is very controlled here). Maybe you could also check out serialization https://github.com/nlohmann/json?tab=readme-ov-file#serialization--deserialization
- Add unit tests for some of the methods of `NostrService`. - Explicitly declare specific usings rather than entire namespaces (e.g., don't to `using namespace std;`). - Add some additional logging with Plog.
- Port existing work over from ShadowySupercode/gitrepublic-core#2 - Adjust project layout and configure CMake scripts accordingly
This PR adds a
nostr
namespace to the project that defines a Nostr client, built using WebSocket++ and nlohmann/json.Notes for Reviewer