diff options
| -rw-r--r-- | bin/main.ml | 3 | ||||
| -rw-r--r-- | lib/core_functions.ml | 2 | ||||
| -rw-r--r-- | lib/disk.ml | 9 | ||||
| -rw-r--r-- | lib/interop.ml | 3 | ||||
| -rw-r--r-- | shared/librelational_engine/library.cpp | 20 | ||||
| -rw-r--r-- | shared/librelational_engine/library.h | 1 |
6 files changed, 5 insertions, 33 deletions
diff --git a/bin/main.ml b/bin/main.ml index 3b718ee..a21c63e 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -1,7 +1,4 @@ -open Relational_engine let () = begin - (* print_endline @@ Interop.Merkle.merkle_generate_root [Disk.Executor._EMPTY_SHA_HASH_] *) - Interop.Merkle.register_to_merkle Disk.Executor._EMPTY_SHA_HASH_; end diff --git a/lib/core_functions.ml b/lib/core_functions.ml index 3d1cd35..7fdf1f1 100644 --- a/lib/core_functions.ml +++ b/lib/core_functions.ml @@ -20,6 +20,4 @@ module Functions (F : Ctypes.FOREIGN) = struct ~filename:((Sys.getenv "LIBRELATIONAL_ENGINE_LIB_PATH") ^ "/librelational_engine." ^ os_extension) let compute_hash = Foreign.foreign ~from:libmerklecpp "compute_hash" (ptr char @-> Ctypes.string @-> returning void) let merkle_generate_root = Foreign.foreign ~from:libmerklecpp "merkle_generate_root" (ptr Ctypes.string @-> int @-> ptr char @-> returning void) - let register_to_merkle = Foreign.foreign ~from:libmerklecpp "register_to_merkle" (Ctypes.string @-> Ctypes.string @-> returning void) - end diff --git a/lib/disk.ml b/lib/disk.ml index aa971dd..fc99607 100644 --- a/lib/disk.ml +++ b/lib/disk.ml @@ -191,12 +191,13 @@ module Command = struct (** TODO: This does not write atomically. If the system crashes while it attempts to write, it will corrupt. Solve this with a temporary file and move later. *) - let commit - (* (_files: Filesystem.files) (_locations: Filesystem.locations) *) - command = + let commit_and_perform (commit: Executor.commit) (locations: Executor.locations) command = let open Extensions.Result in let+ serialized_command = Result.map_error (fun _ -> "Failed to serialize command to binary format.") @@ Binary.to_bytes command_encoding command in - FS.append FS.Transaction serialized_command + let+ _ = FS.append FS.Transaction serialized_command in + match command.kind with + | WRITE -> Executor.write commit locations ~filename:command.filename @@ Bytes.of_string command.content + | _ -> Ok (commit, locations) end diff --git a/lib/interop.ml b/lib/interop.ml index 28b4fb9..fdfde5f 100644 --- a/lib/interop.ml +++ b/lib/interop.ml @@ -16,7 +16,4 @@ module Merkle = struct let hashes = CArray.of_list string hashes in C.Functions.merkle_generate_root (CArray.start hashes) len buf; Ctypes.coerce (ptr char) Ctypes.string buf - - let register_to_merkle content = - C.Functions.register_to_merkle "/tmp/relational-engine/tree" content end diff --git a/shared/librelational_engine/library.cpp b/shared/librelational_engine/library.cpp index cab8f93..0ef8038 100644 --- a/shared/librelational_engine/library.cpp +++ b/shared/librelational_engine/library.cpp @@ -27,26 +27,6 @@ void write_tree(const char* tree_path, const std::vector<uint8_t>& serialized_tr 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<uint8_t> 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<uint8_t> target; - tree.serialise(target); - write_tree(tree_path, target); - } else { - merkle::Tree::Hash hash(computed_hash); - merkle::Tree tree; - tree.insert(hash); - std::vector<uint8_t> 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++){ diff --git a/shared/librelational_engine/library.h b/shared/librelational_engine/library.h index 16734be..ebf8497 100644 --- a/shared/librelational_engine/library.h +++ b/shared/librelational_engine/library.h @@ -5,6 +5,5 @@ 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 |
