diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/odhtdb/Database.hpp | 2 | ||||
-rw-r--r-- | include/odhtdb/DatabaseStorage.hpp | 8 | ||||
-rw-r--r-- | include/odhtdb/FileUtils.hpp | 4 |
3 files changed, 14 insertions, 0 deletions
diff --git a/include/odhtdb/Database.hpp b/include/odhtdb/Database.hpp index 11a6cd4..5ebe9c5 100644 --- a/include/odhtdb/Database.hpp +++ b/include/odhtdb/Database.hpp @@ -187,5 +187,7 @@ namespace odhtdb std::function<void(const DatabaseAddNodeRequest&)> onAddNodeCallbackFunc; std::function<void(const DatabaseAddUserRequest&)> onAddUserCallbackFunc; MapHash<DatabaseSeedInfo> seedInfoMap; + std::thread remoteNodesSaveThread; + bool shuttingDown; }; } diff --git a/include/odhtdb/DatabaseStorage.hpp b/include/odhtdb/DatabaseStorage.hpp index a004619..886412c 100644 --- a/include/odhtdb/DatabaseStorage.hpp +++ b/include/odhtdb/DatabaseStorage.hpp @@ -15,6 +15,7 @@ #include <boost/filesystem/path.hpp> #include <sibs/SafeDeserializer.hpp> #include <opendht/crypto.h> +#include <opendht/dhtrunner.h> #include <functional> class sqlite3; @@ -121,6 +122,9 @@ namespace odhtdb std::pair<bool, std::shared_ptr<OwnedMemory>> getNodeDecryptionKey(const Hash &nodeHash); void setNodeDecryptionKey(const Hash &nodeHash, const DataView &decryptionKey); + const std::vector<dht::NodeExport>& getRemoteNodes() const; + void setRemoteNodes(const std::vector<dht::NodeExport> &remoteNodes); + const dht::crypto::Identity& getIdentity() const; // Update storage state (remove quarantine objects if they are too old, etc) @@ -131,6 +135,7 @@ namespace odhtdb void bindCheckError(int sqliteBindResult); void loadMetadataFromFile(); + void loadRemoteNodesFromFile(); bool decryptNodeData(const Hash &nodeHash, const std::shared_ptr<OwnedMemory> decryptionKey); bool decryptNodeData(const Hash &nodeHash, const std::shared_ptr<OwnedMemory> decryptionKey, const Signature::PublicKey *creatorPublicKey, const DataView &adminGroupId, u64 timestamp); bool decryptNodeAddData(i64 rowId, const Hash &nodeHash, const Hash &dataHash, u64 timestamp, const Signature::PublicKey *creatorPublicKey, const DataView &encryptedData, const std::shared_ptr<OwnedMemory> decryptionKey); @@ -168,7 +173,10 @@ namespace odhtdb sqlite3_stmt *setNodeAddDataAdditionalDataStmt; boost::filesystem::path metadataFilePath; + boost::filesystem::path remoteNodesFilePath; + u8 passwordSalt[PASSWORD_SALT_LEN]; std::pair<std::shared_ptr<dht::crypto::PrivateKey>, std::shared_ptr<dht::crypto::Certificate>> identity; + std::vector<dht::NodeExport> remoteNodes; }; } diff --git a/include/odhtdb/FileUtils.hpp b/include/odhtdb/FileUtils.hpp index 7bfbe3e..88721ed 100644 --- a/include/odhtdb/FileUtils.hpp +++ b/include/odhtdb/FileUtils.hpp @@ -19,4 +19,8 @@ namespace odhtdb // Creates file if it doesn't exist. // Throws FileException on error void fileAppend(const boost::filesystem::path &filepath, const DataView &data); + + // Creates a file if it doesn'te xist. + // Throws FileException on error. + void fileOverwrite(const boost::filesystem::path &filepath, const DataView &data); } |