mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-10 14:58:05 +00:00
limit refreshes per tick to refresh_per_tick_limit=20, fix boost::ref(item)
This commit is contained in:
parent
61b057175f
commit
066435719d
@ -545,6 +545,7 @@ bool node_impl::refresh_storage() {
|
||||
ptime const now = time_now();
|
||||
m_next_storage_refresh = now + minutes(60);
|
||||
|
||||
int refresh_per_tick_limit = 20;
|
||||
|
||||
for (dht_storage_table_t::iterator i = m_storage_table.begin(),
|
||||
end(m_storage_table.end()); i != end; ++i )
|
||||
@ -567,6 +568,8 @@ bool node_impl::refresh_storage() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( refresh_per_tick_limit > 0) {
|
||||
|
||||
lazy_entry p;
|
||||
int pos;
|
||||
error_code err;
|
||||
@ -602,20 +605,24 @@ bool node_impl::refresh_storage() {
|
||||
// search for nodes with ids close to id or with peers
|
||||
// for info-hash id. then send putData to them.
|
||||
boost::intrusive_ptr<dht_get> ta(new dht_get(*this, username, resource, multi,
|
||||
boost::bind(&putData_confirm, item),
|
||||
boost::bind(&putData_confirm, boost::ref(item)),
|
||||
boost::bind(&putData_fun, _1, boost::ref(*this),
|
||||
entryP, item.sig_p, item.sig_user), item.confirmed));
|
||||
ta->start();
|
||||
did_something = true;
|
||||
|
||||
--refresh_per_tick_limit;
|
||||
|
||||
// add 10% diffusion to next refresh time
|
||||
item.next_refresh_time = now + minutes(item.confirmed ? 60 : 1) * (1. + 0.1 * (2. * getRandom() - 1.));
|
||||
}
|
||||
}
|
||||
|
||||
if( m_next_storage_refresh > item.next_refresh_time ) {
|
||||
m_next_storage_refresh = item.next_refresh_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
printf("node dht: next storage refresh in %s\n",
|
||||
|
Loading…
Reference in New Issue
Block a user