Browse Source

optimization. should *greatly* reduce cpu usage. #136

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
acbd61e93d
  1. 2
      libtorrent/include/libtorrent/kademlia/node.hpp
  2. 6
      libtorrent/src/kademlia/node.cpp

2
libtorrent/include/libtorrent/kademlia/node.hpp

@ -181,7 +181,7 @@ public:
void tick(); void tick();
bool refresh_storage(); 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; bool save_storage(entry &save) const;
void refresh(node_id const& id, find_data::nodes_callback const& f); void refresh(node_id const& id, find_data::nodes_callback const& f);
void bootstrap(std::vector<udp::endpoint> const& nodes void bootstrap(std::vector<udp::endpoint> const& nodes

6
libtorrent/src/kademlia/node.cpp

@ -509,7 +509,7 @@ bool node_impl::refresh_storage() {
} }
#ifdef ENABLE_DHT_ITEM_EXPIRE #ifdef ENABLE_DHT_ITEM_EXPIRE
if( has_expired(item) ) { if( has_expired(item, true) ) {
continue; continue;
} }
#endif #endif
@ -580,12 +580,12 @@ bool node_impl::refresh_storage() {
return did_something; 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 // dont expire if block chain is invalid
if( getBestHeight() < 1 ) if( getBestHeight() < 1 )
return false; 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 // invalid signature counts as expired
printf("node_impl::has_expired verifySignature failed\n"); printf("node_impl::has_expired verifySignature failed\n");
return true; return true;

Loading…
Cancel
Save