From 0150dd2f7b7556bd39d6293720f204ba6dad2266 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 22 Oct 2013 18:32:04 -0200 Subject: [PATCH] support to disable loading/refreshing of expired dht keys --- libtorrent/src/kademlia/node.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index f6d28f41..4675c92f 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -55,6 +55,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/rsa.hpp" #include "../../src/twister.h" +//#define ENABLE_DHT_ITEM_EXPIRE namespace libtorrent { namespace dht { @@ -502,6 +503,12 @@ bool node_impl::refresh_storage() { if( lsto.size() == 1 ) { dht_storage_item const& item = lsto.front(); +#ifdef ENABLE_DHT_ITEM_EXPIRE + if( has_expired(item) ) { + continue; + } +#endif + lazy_entry p; int pos; error_code err; @@ -638,9 +645,14 @@ void node_impl::load_storage(entry const* e) { item.sig_user = j->find_key("sig_user")->string(); // just for printf for now - has_expired(item); - - to_add.push_back(item); + bool expired = has_expired(item); +#ifdef ENABLE_DHT_ITEM_EXPIRE + if( !expired ) { +#endif + to_add.push_back(item); +#ifdef ENABLE_DHT_ITEM_EXPIRE + } +#endif } m_storage_table.insert(std::make_pair(target, to_add)); }