aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-21 14:31:28 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commit0d83a5c6070cd02449571879c5be0c4c441e81b7 (patch)
tree8d2971cb9592fc80e81a6ce6b5e1c3bff349f258 /include
parent3a9ba6b080d2820783fbd81c4ebd97b36b24ac68 (diff)
Async connect
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;