#pragma once #include "types.hpp" #include "Key.hpp" #include "StagedObject.hpp" #include "DataView.hpp" #include "DatabaseStorage.hpp" #include #include #include #include namespace odhtdb { class LocalUser; class Database { public: Database(const char *bootstrapNodeAddr, u16 port, boost::filesystem::path storageDir); ~Database(); void seed(); void create(LocalUser *owner, const Key &key); void add(LocalUser *owner, const Key &key, DataView data); void commit(); private: void commitStagedCreateObject(const StagedCreateObject &stagedObject); void commitStagedAddObject(const StagedAddObject &stagedObject); ntp::NtpTimestamp getSyncedTimestampUtc() const; StagedCreateObject deserializeCreateRequest(const std::shared_ptr &value); StagedAddObject deserializeAddRequest(const std::shared_ptr &value); bool listenCreateData(std::shared_ptr value); bool listenAddData(std::shared_ptr value); private: dht::DhtRunner node; std::vector stagedCreateObjects; std::vector stagedAddObjects; DatabaseStorage databaseStorage; }; }