aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/odhtdb/Database.hpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/odhtdb/Database.hpp b/include/odhtdb/Database.hpp
index a326398..61365a0 100644
--- a/include/odhtdb/Database.hpp
+++ b/include/odhtdb/Database.hpp
@@ -162,7 +162,7 @@ namespace odhtdb
DISABLE_COPY(Database)
friend class DatabaseStorage;
public:
- Database(const char *bootstrapNodeAddr, u16 port, const boost::filesystem::path &storageDir, DatabaseCallbackFuncs callbackFuncs);
+ static std::future<std::unique_ptr<Database>> connect(const char *bootstrapNodeAddr, u16 port, const boost::filesystem::path &storageDir, DatabaseCallbackFuncs callbackFuncs);
~Database();
// Safe to call multiple times with same node hash, will be ignored if the node is already beeing seeded
@@ -212,13 +212,15 @@ namespace odhtdb
static InfoHash getInfoHash(const void *data, usize size);
private:
+ Database(const sibs::Ipv4 &bootstrapNodeAddr, const boost::filesystem::path &storageDir, DatabaseCallbackFuncs callbackFuncs);
+
bool sendOldDataToPeer(const DatabaseNode nodeToSeed, const void *data, const usize size);
void deserializeCreateRequest(const void *data, const usize size, const Hash &hash, const std::shared_ptr<OwnedByteArray> encryptionKey);
void deserializeAddRequest(const void *data, const usize size, const Hash &requestDataHash, const std::shared_ptr<Hash> &nodeHash, const std::shared_ptr<OwnedByteArray> encryptionKey);
bool listenCreateData(const void *data, const usize size, const Hash &hash, const std::shared_ptr<OwnedByteArray> encryptionKey);
bool listenAddData(const void *data, const usize size, const Hash &requestDataHash, const std::shared_ptr<Hash> nodeHash, const std::shared_ptr<OwnedByteArray> encryptionKey);
private:
- sibs::BootstrapConnection bootstrapConnection;
+ std::unique_ptr<sibs::BootstrapConnection> bootstrapConnection;
DatabaseStorage databaseStorage;
std::function<void(const DatabaseCreateNodeRequest&)> onCreateNodeCallbackFunc;
std::function<void(const DatabaseAddNodeRequest&)> onAddNodeCallbackFunc;