aboutsummaryrefslogtreecommitdiff
path: root/include/Database.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-02-03 19:33:05 +0100
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:12 +0200
commit5c1a20c4dacfe03db90b70c2665e66a76574196c (patch)
tree5d2d418f7ac0f84aba8439e75683b1f53f053465 /include/Database.hpp
parent1c7e6e074155499155adbbb651db1c66f1762ba2 (diff)
Add seed function, not yet finished
Diffstat (limited to 'include/Database.hpp')
-rw-r--r--include/Database.hpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/include/Database.hpp b/include/Database.hpp
index 20d7513..68fff62 100644
--- a/include/Database.hpp
+++ b/include/Database.hpp
@@ -2,6 +2,7 @@
#include "types.hpp"
#include "Key.hpp"
+#include "StagedObject.hpp"
#include "DataView.hpp"
#include <opendht/dhtrunner.h>
#include <vector>
@@ -11,26 +12,13 @@ namespace odhtdb
{
class Group;
- struct StagedCreateObject
- {
- Key key;
- Group *primaryAdminGroup;
- u64 timestamp; // In microseconds
- };
-
- struct StagedAddObject
- {
- Key key;
- DataView data;
- u64 timestamp; // In microseconds
- };
-
class Database
{
public:
Database(const char *bootstrapNodeAddr, u16 port);
~Database();
+ void seed();
void create(const Key &key, Group *primaryAdminGroup);
void add(const Key &key, DataView data);
void commit();
@@ -38,6 +26,10 @@ namespace odhtdb
void commitStagedCreateObject(const StagedCreateObject &stagedObject);
void commitStagedAddObject(const StagedAddObject &stagedObject);
ntp::NtpTimestamp getSyncedTimestampUtc() const;
+ StagedCreateObject deserializeCreateRequest(const std::shared_ptr<dht::Value> &value);
+ StagedAddObject deserializeAddRequest(const std::shared_ptr<dht::Value> &value);
+ bool listenCreateData(const std::vector<std::shared_ptr<dht::Value>> &values);
+ bool listenAddData(const std::vector<std::shared_ptr<dht::Value>> &values);
private:
dht::DhtRunner node;
std::vector<StagedCreateObject> stagedCreateObjects;