aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-10-21 14:31:28 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-10-21 14:31:28 +0200
commit22abf1aa83b2668f918556491a55947be798f89f (patch)
tree7d4658eaf7cf679a4955e6b86fa2bb389002e096 /include
parentacb17dec61717e2577cec9272ce22e2c8f7a2851 (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;