From 32bb72b527966c1b7324afcd7fae466fc84b30d6 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Mon, 27 May 2024 12:09:41 -0500 Subject: refactor so no project header imports nostr.hpp --- src/data/event.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/data/event.cpp') diff --git a/src/data/event.cpp b/src/data/event.cpp index 5f611ff..bd37ee7 100644 --- a/src/data/event.cpp +++ b/src/data/event.cpp @@ -1,13 +1,12 @@ +#include +#include + #include "data/data.hpp" using namespace nlohmann; using namespace std; -namespace nostr -{ -namespace data -{ -string Event::serialize() +string nostr::data::Event::serialize() { try { @@ -31,7 +30,7 @@ string Event::serialize() return j.dump(); }; -Event Event::fromString(string jstr) +nostr::data::Event nostr::data::Event::fromString(string jstr) { json j = json::parse(jstr); Event event; @@ -48,7 +47,7 @@ Event Event::fromString(string jstr) return event; }; -Event Event::fromJson(json j) +nostr::data::Event nostr::data::Event::fromJson(json j) { Event event; @@ -69,7 +68,7 @@ Event Event::fromJson(json j) return event; }; -void Event::validate() +void nostr::data::Event::validate() { bool hasPubkey = this->pubkey.length() > 0; if (!hasPubkey) @@ -90,7 +89,7 @@ void Event::validate() } }; -string Event::generateId(string serializedData) const +string nostr::data::Event::generateId(string serializedData) const { unsigned char hash[SHA256_DIGEST_LENGTH]; EVP_Digest(serializedData.c_str(), serializedData.length(), hash, NULL, EVP_sha256(), NULL); @@ -104,7 +103,7 @@ string Event::generateId(string serializedData) const return ss.str(); }; -bool Event::operator==(const Event& other) const +bool nostr::data::Event::operator==(const Event& other) const { if (this->id.empty()) { @@ -117,5 +116,3 @@ bool Event::operator==(const Event& other) const return this->id == other.id; }; -} // namespace data -} // namespace nostr -- cgit