aboutsummaryrefslogtreecommitdiff
path: root/include/Database.hpp
diff options
context:
space:
mode:
authorAleksi Lindeman <aleksi_888@hotmail.com>2018-02-01 21:15:13 +0100
committerAleksi Lindeman <aleksi_888@hotmail.com>2018-02-01 21:15:19 +0100
commit6f1089db78f14b52b869f5aaa979e52ff5e4c2d7 (patch)
treed79f7abfb0fb9f3d58f9716741512b63fb4193ec /include/Database.hpp
parent80a9c135b8bdca64246f147f22d98485e0f05ee5 (diff)
Sync time with ntp server, starting with basic operations
Diffstat (limited to 'include/Database.hpp')
-rw-r--r--include/Database.hpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/include/Database.hpp b/include/Database.hpp
index 0b324e8..20d7513 100644
--- a/include/Database.hpp
+++ b/include/Database.hpp
@@ -5,13 +5,24 @@
#include "DataView.hpp"
#include <opendht/dhtrunner.h>
#include <vector>
+#include <ntp/NtpClient.hpp>
namespace odhtdb
{
- struct StagedObject
+ class Group;
+
+ struct StagedCreateObject
+ {
+ Key key;
+ Group *primaryAdminGroup;
+ u64 timestamp; // In microseconds
+ };
+
+ struct StagedAddObject
{
Key key;
DataView data;
+ u64 timestamp; // In microseconds
};
class Database
@@ -20,12 +31,16 @@ namespace odhtdb
Database(const char *bootstrapNodeAddr, u16 port);
~Database();
+ void create(const Key &key, Group *primaryAdminGroup);
void add(const Key &key, DataView data);
void commit();
private:
- void commitStagedObject(const StagedObject &stagedObject);
+ void commitStagedCreateObject(const StagedCreateObject &stagedObject);
+ void commitStagedAddObject(const StagedAddObject &stagedObject);
+ ntp::NtpTimestamp getSyncedTimestampUtc() const;
private:
dht::DhtRunner node;
- std::vector<StagedObject> stagedObjects;
+ std::vector<StagedCreateObject> stagedCreateObjects;
+ std::vector<StagedAddObject> stagedAddObjects;
};
} \ No newline at end of file