From acbd61e93d918f3ea1c6ede7d36e78b9b3763a30 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Thu, 30 Jan 2014 19:29:40 -0200 Subject: [PATCH] optimization. should *greatly* reduce cpu usage. #136 --- libtorrent/include/libtorrent/kademlia/node.hpp | 2 +- libtorrent/src/kademlia/node.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libtorrent/include/libtorrent/kademlia/node.hpp b/libtorrent/include/libtorrent/kademlia/node.hpp index ad383e76..6ca43c7d 100644 --- a/libtorrent/include/libtorrent/kademlia/node.hpp +++ b/libtorrent/include/libtorrent/kademlia/node.hpp @@ -181,7 +181,7 @@ public: void tick(); bool refresh_storage(); - bool has_expired(dht_storage_item const& item); + bool has_expired(dht_storage_item const& item, bool skipSigCheck=false); bool save_storage(entry &save) const; void refresh(node_id const& id, find_data::nodes_callback const& f); void bootstrap(std::vector const& nodes diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index 37e20ebb..0bea1ad6 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -509,7 +509,7 @@ bool node_impl::refresh_storage() { } #ifdef ENABLE_DHT_ITEM_EXPIRE - if( has_expired(item) ) { + if( has_expired(item, true) ) { continue; } #endif @@ -580,12 +580,12 @@ bool node_impl::refresh_storage() { return did_something; } -bool node_impl::has_expired(dht_storage_item const& item) { +bool node_impl::has_expired(dht_storage_item const& item, bool skipSigCheck) { // dont expire if block chain is invalid if( getBestHeight() < 1 ) return false; - if (!verifySignature(item.p, item.sig_user, item.sig_p)) { + if (!skipSigCheck && !verifySignature(item.p, item.sig_user, item.sig_p)) { // invalid signature counts as expired printf("node_impl::has_expired verifySignature failed\n"); return true;