From 955af06e29c49f66787b8a9cca5661722eea4823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Wed, 20 Apr 2022 15:56:05 -0400 Subject: [PATCH] dht: add getStorageLimit --- include/opendht/dht.h | 3 +++ include/opendht/dht_interface.h | 1 + include/opendht/dht_proxy_client.h | 1 + include/opendht/dhtrunner.h | 1 + include/opendht/securedht.h | 4 ++++ 5 files changed, 10 insertions(+) diff --git a/include/opendht/dht.h b/include/opendht/dht.h index 6e8132f4..7722ebfb 100644 --- a/include/opendht/dht.h +++ b/include/opendht/dht.h @@ -302,6 +302,9 @@ public: void setStorageLimit(size_t limit = DEFAULT_STORAGE_LIMIT) override { max_store_size = limit; } + size_t getStorageLimit() const override { + return max_store_size; + } /** * Returns the total memory usage of stored values and the number diff --git a/include/opendht/dht_interface.h b/include/opendht/dht_interface.h index cfca964d..bb0362f0 100644 --- a/include/opendht/dht_interface.h +++ b/include/opendht/dht_interface.h @@ -221,6 +221,7 @@ public: * Set the in-memory storage limit in bytes */ virtual void setStorageLimit(size_t limit = DEFAULT_STORAGE_LIMIT) = 0; + virtual size_t getStorageLimit() const = 0; /** * Returns the total memory usage of stored values and the number diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index 9dd6db24..3c011b43 100644 --- a/include/opendht/dht_proxy_client.h +++ b/include/opendht/dht_proxy_client.h @@ -263,6 +263,7 @@ public: void dumpTables() const override {} std::vector<unsigned> getNodeMessageStats(bool) override { return {}; } void setStorageLimit(size_t) override {} + virtual size_t getStorageLimit() const { return 0; } void connectivityChanged(sa_family_t) override { getProxyInfos(); } diff --git a/include/opendht/dhtrunner.h b/include/opendht/dhtrunner.h index 5acf6794..11e3810e 100644 --- a/include/opendht/dhtrunner.h +++ b/include/opendht/dhtrunner.h @@ -335,6 +335,7 @@ public: std::pair<size_t, size_t> getStoreSize() const; + void getStorageLimit() const; void setStorageLimit(size_t limit = DEFAULT_STORAGE_LIMIT); std::vector<NodeExport> exportNodes() const; diff --git a/include/opendht/securedht.h b/include/opendht/securedht.h index 73f03abb..f73e5a1d 100644 --- a/include/opendht/securedht.h +++ b/include/opendht/securedht.h @@ -173,6 +173,10 @@ public: void setStorageLimit(size_t limit = DEFAULT_STORAGE_LIMIT) override { dht_->setStorageLimit(limit); } + size_t getStorageLimit() const override { + return dht_->getStorageLimit(); + } + std::vector<NodeExport> exportNodes() const override { return dht_->exportNodes(); } -- GitLab