blob: 68fff62fafee6d78d15ab7c8364071c9401b4b8a (
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
|
#pragma once
#include "types.hpp"
#include "Key.hpp"
#include "StagedObject.hpp"
#include "DataView.hpp"
#include <opendht/dhtrunner.h>
#include <vector>
#include <ntp/NtpClient.hpp>
namespace odhtdb
{
class Group;
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();
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;
};
}
|