From 3063608df6ff1668f683d9d22c57fea29d728d0d Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Tue, 11 Nov 2025 00:00:43 -0300 Subject: migrating to erlang to attach to mnesia --- shared/librelational_engine/CMakeLists.txt | 12 ----- shared/librelational_engine/library.cpp | 73 ------------------------------ shared/librelational_engine/library.h | 10 ---- 3 files changed, 95 deletions(-) delete mode 100644 shared/librelational_engine/CMakeLists.txt delete mode 100644 shared/librelational_engine/library.cpp delete mode 100644 shared/librelational_engine/library.h (limited to 'shared/librelational_engine') diff --git a/shared/librelational_engine/CMakeLists.txt b/shared/librelational_engine/CMakeLists.txt deleted file mode 100644 index d22d0d0..0000000 --- a/shared/librelational_engine/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.29) -project(relational_engine) - -include_directories($ENV{LIBRESSL_INCLUDE_PATH}) -include_directories($ENV{MERKLECPP_INCLUDE_PATH}) - -add_library(relational_engine SHARED library.cpp) - -target_link_libraries(relational_engine - $ENV{LIBRESSL_LIB_PATH}/libssl.$ENV{OS_LIB_EXTENSION} - $ENV{LIBRESSL_LIB_PATH}/libcrypto.$ENV{OS_LIB_EXTENSION} -) \ No newline at end of file diff --git a/shared/librelational_engine/library.cpp b/shared/librelational_engine/library.cpp deleted file mode 100644 index cab8f93..0000000 --- a/shared/librelational_engine/library.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -std::vector read_tree(const char* tree_path) { - std::ifstream file(tree_path, std::ios::binary); - file.unsetf(std::ios::skipws); - file.seekg(0, std::ios::end); - const std::streampos file_size = file.tellg(); - file.seekg(0, std::ios::beg); - std::vector v; - v.reserve(file_size); - v.insert(v.begin(), std::istream_iterator(file), std::istream_iterator()); - return v; -} - -void write_tree(const char* tree_path, const std::vector& serialized_tree) { - std::ofstream out(tree_path, std::ios::out | std::ios::binary); - out.write(reinterpret_cast(serialized_tree.data()), serialized_tree.size()); - out.close(); -} - -extern "C" { -#include "library.h" - extern void register_to_merkle(const char* tree_path, const char* computed_hash) { - struct stat st; - if (stat(tree_path, &st) == 0) { - const std::vector tree_bytes = read_tree(tree_path); - merkle::Tree tree; - tree.deserialise(tree_bytes); - const merkle::Tree::Hash hash(computed_hash); - tree.insert(hash); - std::vector target; - tree.serialise(target); - write_tree(tree_path, target); - } else { - merkle::Tree::Hash hash(computed_hash); - merkle::Tree tree; - tree.insert(hash); - std::vector target; - tree.serialise(target); - write_tree(tree_path, target); - } - } - extern void merkle_generate_root(char** hashes, const int n, char* root) { - merkle::Tree tree; - for (int i = 0; i < n; i++){ - tree.insert(merkle::Hash(hashes[i])); - } - std::memcpy(root, tree.root().to_string().c_str(), HASH_SIZE); - } - extern void compute_hash(char* computed_hash, const char *content) { - - unsigned char hash[SHA256_DIGEST_LENGTH]; - SHA256_CTX sha256; - SHA256_Init(&sha256); - SHA256_Update(&sha256, content, sizeof(content)); - SHA256_Final(hash, &sha256); - std::stringstream ss; - for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) - ss << std::hex << std::setw(2) << std::setfill('0') << static_cast(hash[i]); - - std::memcpy(computed_hash, ss.str().c_str(), HASH_SIZE); - // std::cout << "⚙️ COMPUTED HASH: " << computed_hash << std::endl; - } - - extern int trash() { return 100; } -} diff --git a/shared/librelational_engine/library.h b/shared/librelational_engine/library.h deleted file mode 100644 index 16734be..0000000 --- a/shared/librelational_engine/library.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef MERKLECPP_STUB_LIBRARY_H -#define MERKLECPP_STUB_LIBRARY_H - -#define HASH_SIZE 64 - -extern void merkle_generate_root(char**, const int, char*); -extern void compute_hash(char*, const char*); -extern void register_to_merkle(const char*, const char*); - -#endif //MERKLECPP_STUB_LIBRARY_H -- cgit v1.2.3