aboutsummaryrefslogtreecommitdiff
path: root/include/Database.hpp
blob: 0b324e8f5249fc4aae56891d7e6fcf86889d1fe0 (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
#pragma once

#include "types.hpp"
#include "Key.hpp"
#include "DataView.hpp"
#include <opendht/dhtrunner.h>
#include <vector>

namespace odhtdb
{
    struct StagedObject
    {
        Key key;
        DataView data;
    };

    class Database
    {
    public:
        Database(const char *bootstrapNodeAddr, u16 port);
        ~Database();

        void add(const Key &key, DataView data);
        void commit();
    private:
        void commitStagedObject(const StagedObject &stagedObject);
    private:
        dht::DhtRunner node;
        std::vector<StagedObject> stagedObjects;
    };
}