mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 20:44:56 +00:00
commit
5f3bcf2d11
@ -300,6 +300,7 @@ private:
|
|||||||
|
|
||||||
ptime m_last_tracker_tick;
|
ptime m_last_tracker_tick;
|
||||||
ptime m_next_storage_refresh;
|
ptime m_next_storage_refresh;
|
||||||
|
int m_refresh_per_tick;
|
||||||
std::pair<node_id, int> m_last_refreshed_item;
|
std::pair<node_id, int> m_last_refreshed_item;
|
||||||
|
|
||||||
// secret random numbers used to create write tokens
|
// secret random numbers used to create write tokens
|
||||||
|
@ -579,8 +579,8 @@ bool node_impl::refresh_storage() {
|
|||||||
(multi && item.local_add_time && item.local_add_time + 60*60*24*2 > time(NULL)) ) {
|
(multi && item.local_add_time && item.local_add_time + 60*60*24*2 > time(NULL)) ) {
|
||||||
num_refreshable++;
|
num_refreshable++;
|
||||||
|
|
||||||
if( refresh_next_item ) {
|
if( refresh_next_item && m_refresh_per_tick ) {
|
||||||
refresh_next_item = false;
|
--m_refresh_per_tick;
|
||||||
m_last_refreshed_item = std::make_pair(i->first,jIdx);
|
m_last_refreshed_item = std::make_pair(i->first,jIdx);
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
printf("node dht: refreshing storage: [%s,%s,%s]\n",
|
printf("node dht: refreshing storage: [%s,%s,%s]\n",
|
||||||
@ -611,13 +611,16 @@ bool node_impl::refresh_storage() {
|
|||||||
m_last_refreshed_item = std::make_pair(m_storage_table.begin()->first,0);
|
m_last_refreshed_item = std::make_pair(m_storage_table.begin()->first,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
time_duration sleepToRefresh;
|
const time_duration tickInterval = seconds(5);
|
||||||
if( num_refreshable ) {
|
const time_duration fullRefreshInterval = minutes(30);
|
||||||
sleepToRefresh = minutes(60) / num_refreshable;
|
const time_duration sleepInterval = minutes(10);
|
||||||
} else {
|
const time_duration sleepToRefresh = std::min( sleepInterval, fullRefreshInterval / (num_refreshable ? num_refreshable : 1) );
|
||||||
sleepToRefresh = minutes(10);
|
|
||||||
}
|
|
||||||
m_next_storage_refresh = time_now() + sleepToRefresh;
|
m_next_storage_refresh = time_now() + sleepToRefresh;
|
||||||
|
if( sleepToRefresh > tickInterval ) {
|
||||||
|
m_refresh_per_tick = 1;
|
||||||
|
} else {
|
||||||
|
m_refresh_per_tick = tickInterval.diff/sleepToRefresh.diff;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
printf("node dht: next storage refresh in %s\n",
|
printf("node dht: next storage refresh in %s\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user