blob: bde4d5a34ce83f4e89542dcd33f31e2cfe9fc009 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include "types.hpp"
#include "Key.hpp"
#include "StagedObject.hpp"
#include "DataView.hpp"
#include <opendht/dhtrunner.h>
#include <vector>
#include <ntp/NtpClient.hpp>
#include <boost/filesystem/path.hpp>
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<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;
std::vector<StagedAddObject> stagedAddObjects;
};
}
|