From 45c0c31c54d4dd9f164db770ebede5087bbc8aef Mon Sep 17 00:00:00 2001 From: dec05eba <0xdec05eba@gmail.com> Date: Mon, 21 May 2018 01:02:11 +0200 Subject: Ping node before sending old data --- include/odhtdb/Database.hpp | 3 +++ include/odhtdb/DatabaseStorage.hpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/odhtdb/Database.hpp b/include/odhtdb/Database.hpp index a2914ac..6874fe0 100644 --- a/include/odhtdb/Database.hpp +++ b/include/odhtdb/Database.hpp @@ -201,8 +201,11 @@ namespace odhtdb // Return true in @callbackFunc if you want to continue listening for responses, otherwise return false void sendCustomMessage(const dht::InfoHash &key, std::vector &&data, SendCustomMessageCallbackFunc callbackFunc); + int clearCache(); + static dht::InfoHash getInfoHash(const void *data, usize size); private: + void sendOldDataToPeer(const DatabaseNode nodeToSeed, const std::shared_ptr requestResponseInfoHash, const std::shared_ptr value, usize valueOffset); void deserializeCreateRequest(const std::shared_ptr &value, const Hash &hash, const std::shared_ptr encryptionKey); void deserializeAddRequest(const std::shared_ptr &value, const Hash &requestDataHash, const std::shared_ptr &nodeHash, const std::shared_ptr encryptionKey); bool listenCreateData(std::shared_ptr value, const Hash &hash, const std::shared_ptr encryptionKey); diff --git a/include/odhtdb/DatabaseStorage.hpp b/include/odhtdb/DatabaseStorage.hpp index 9f93994..757fbfd 100644 --- a/include/odhtdb/DatabaseStorage.hpp +++ b/include/odhtdb/DatabaseStorage.hpp @@ -148,6 +148,9 @@ namespace odhtdb // Update storage state (remove quarantine objects if they are too old, etc) void update(); + + // Return number of bytes cleared + int clearCache(); private: void init(const boost::filesystem::path &storagePath); void cleanup(); -- cgit v1.2.3