From db3a4e52b2c4dc40deae88adc2ce33024022b7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Fri, 22 Apr 2022 20:18:20 -0400 Subject: [PATCH] dht: add config max_store_keys --- include/opendht/callbacks.h | 3 +++ src/dht.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/opendht/callbacks.h b/include/opendht/callbacks.h index 5ae7d670..88eeff42 100644 --- a/include/opendht/callbacks.h +++ b/include/opendht/callbacks.h @@ -134,6 +134,9 @@ struct OPENDHT_PUBLIC Config { /* If non-0, overrides the default maximum store size. -1 means no limit. */ ssize_t max_store_size {0}; + /* If non-0, overrides the default maximum store key count. -1 means no limit. */ + ssize_t max_store_keys {0}; + /** * Use appropriate bahavior for a public IP, stable node: * - No connectivity change triggered when a search fails diff --git a/src/dht.cpp b/src/dht.cpp index 3755b4b2..946102c2 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -1793,7 +1793,8 @@ Dht::Dht(std::unique_ptr<net::DatagramSocket>&& sock, const Config& config, cons myid(config.node_id ? config.node_id : InfoHash::getRandom(rd)), store(), store_quota(), - max_store_keys(config.max_store_size ? (int)config.max_store_size : MAX_HASHES), + max_store_keys(config.max_store_keys ? (int)config.max_store_keys : MAX_HASHES), + max_store_size(config.max_store_size ? (int)config.max_store_size : DEFAULT_STORAGE_LIMIT), max_searches(config.max_searches ? (int)config.max_searches : MAX_SEARCHES), network_engine(myid, fromDhtConfig(config), std::move(sock), logger_, rd, scheduler, std::bind(&Dht::onError, this, _1, _2), -- GitLab