#pragma once #include "types.hpp" #include "Key.hpp" #include "StagedObject.hpp" #include "DataView.hpp" #include #include #include #include namespace odhtdb { class Group; class Database { public: Database(const char *bootstrapNodeAddr, u16 port, boost::filesystem::path storageDir); ~Database(); void seed(); void create(const Key &key, Group *primaryAdminGroup); void add(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; }; }