aboutsummaryrefslogtreecommitdiffstats
path: root/src/RelationalNT.cpp
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-05-13 01:59:22 -0300
committerGitHub <noreply@github.com>2026-05-13 01:59:22 -0300
commitaf6073dedffd1a16aff7a283ded50545dc40b179 (patch)
treea4b8fbfb4842f5ac27bf7fa641555de3fac6b7f3 /src/RelationalNT.cpp
parentc1b70cfe745d935bded3053fba8c1f9573aa07aa (diff)
downloadRNT-af6073dedffd1a16aff7a283ded50545dc40b179.tar.gz
RNT-af6073dedffd1a16aff7a283ded50545dc40b179.zip
Extern handles for embedded runtime
Diffstat (limited to 'src/RelationalNT.cpp')
-rw-r--r--src/RelationalNT.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/RelationalNT.cpp b/src/RelationalNT.cpp
index e82b8c9..acf7ecb 100644
--- a/src/RelationalNT.cpp
+++ b/src/RelationalNT.cpp
@@ -5,6 +5,7 @@
#include "HandlerManager.h"
#include "IdentityManager.h"
#include "LifecycleManager.h"
+#include "Merkle.h"
#include "ObjectManager.h"
#include "PermissionsManager.h"
#include "SqliteBackend.h"
@@ -40,15 +41,18 @@ int main()
type->disposable = false;
type->methods = { OPEN, CLOSE };
- objects.Register({ "multigroups", "sakura", "relations", "villager" }, std::make_unique<nt::ObjectManager::Relation>(), std::move(type));
+ const std::vector<std::string> path = { "multigroups", "sakura", "relations", "villager" };
+ objects.Register(path, std::make_unique<nt::ObjectManager::Relation>(), std::move(type));
+ auto* villager_rel = dynamic_cast<nt::ObjectManager::Relation*>(
+ objects.Find(path)->object.get());
- // --- Populate SQLite backend with three tuples ---
+ // --- Populate backend with three tuples via the Merkle tree ---
nt::SqliteBackend backend;
- const std::vector<std::string> path = { "multigroups", "sakura", "relations", "villager" };
auto store = [&](std::vector<nt::Attribute> attrs) {
auto bytes = nt::TupleCodec::Serialize(attrs);
- auto hash = backend.Put(bytes);
- backend.LinkTuple(path, hash);
+ auto hash = backend.Put(std::move(bytes));
+ villager_rel->merkle_root =
+ nt::Merkle::Insert(backend, villager_rel->merkle_root, hash);
};
store({ { "name", "Blathers" }, { "profession", "Museum Curator" } });
store({ { "name", "Rover" }, { "profession", "Traveller" } });
@@ -62,7 +66,7 @@ int main()
nt::HandlerManager handler(objects, permissions, identities, lifecycles);
int connection = 1; // dummy connection context
- nt::HandlerManager::handle* handle = handler.Open({ "multigroups", "sakura", "relations", "villager" }, &connection);
+ nt::HandlerManager::handle* handle = handler.Open(path, &connection);
if (handle == nullptr)
{
std::cout << "Failed to open handle for villager\n";
@@ -70,7 +74,7 @@ int main()
}
// --- Open a cursor on the relation ---
- nt::CursorManager::cursor* cursor = cursors.Open(handle);
+ nt::CursorManager::cursor* cursor = cursors.Open(handle, villager_rel->merkle_root);
if (cursor == nullptr)
{
std::cout << "Failed to open cursor for villager\n";