diff --git a/include/opendht/callbacks.h b/include/opendht/callbacks.h index 5ae7d670ce736136b353af96a8b444f9a6ffd7b3..88eeff425cb1541340110592b98f9bd08e8a1d11 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 3755b4b25fca9b7cfd5598b40308c4ae5531709c..946102c2a967f487980fb51ac08f2ae8f6fea680 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),