lt sync 2202
This commit is contained in:
parent
809007d77c
commit
19dcc3e09b
|
@ -138,6 +138,9 @@ namespace libtorrent
|
||||||
m_total_upload_payload += uploaded;
|
m_total_upload_payload += uploaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_type last_payload_downloaded() const { return m_downloaded_payload; }
|
||||||
|
size_type last_payload_uploaded() const { return m_uploaded_payload; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
|
@ -99,6 +99,7 @@ namespace libtorrent
|
||||||
time_duration operator/(int rhs) const { return time_duration(diff / rhs); }
|
time_duration operator/(int rhs) const { return time_duration(diff / rhs); }
|
||||||
explicit time_duration(boost::int64_t d) : diff(d) {}
|
explicit time_duration(boost::int64_t d) : diff(d) {}
|
||||||
time_duration& operator-=(time_duration const& c) { diff -= c.diff; return *this; }
|
time_duration& operator-=(time_duration const& c) { diff -= c.diff; return *this; }
|
||||||
|
time_duration& operator+=(time_duration const& c) { diff += c.diff; return *this; }
|
||||||
time_duration operator+(time_duration const& c) { return time_duration(diff + c.diff); }
|
time_duration operator+(time_duration const& c) { return time_duration(diff + c.diff); }
|
||||||
boost::int64_t diff;
|
boost::int64_t diff;
|
||||||
};
|
};
|
||||||
|
|
|
@ -518,6 +518,7 @@ namespace libtorrent
|
||||||
torrent_handle get_handle();
|
torrent_handle get_handle();
|
||||||
|
|
||||||
void write_resume_data(entry& rd) const;
|
void write_resume_data(entry& rd) const;
|
||||||
|
void read_resume_data(entry const& rd);
|
||||||
|
|
||||||
// LOGGING
|
// LOGGING
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
|
@ -838,6 +839,23 @@ namespace libtorrent
|
||||||
int m_deficit_counter;
|
int m_deficit_counter;
|
||||||
|
|
||||||
policy m_policy;
|
policy m_policy;
|
||||||
|
|
||||||
|
// the sequence number for this torrent, this is a
|
||||||
|
// monotonically increasing number for each added torrent
|
||||||
|
int m_sequence_number;
|
||||||
|
|
||||||
|
// total time we've been available on this torrent
|
||||||
|
// does not count when the torrent is stopped or paused
|
||||||
|
time_duration m_active_time;
|
||||||
|
|
||||||
|
// total time we've been available as a seed on this torrent
|
||||||
|
// does not count when the torrent is stopped or paused
|
||||||
|
time_duration m_seeding_time;
|
||||||
|
|
||||||
|
// all time totals of uploaded and downloaded payload
|
||||||
|
// stored in resume data
|
||||||
|
size_type m_total_uploaded;
|
||||||
|
size_type m_total_downloaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ptime torrent::next_announce() const
|
inline ptime torrent::next_announce() const
|
||||||
|
|
|
@ -114,6 +114,10 @@ namespace libtorrent
|
||||||
, storage_mode(storage_mode_sparse)
|
, storage_mode(storage_mode_sparse)
|
||||||
, up_bandwidth_queue(0)
|
, up_bandwidth_queue(0)
|
||||||
, down_bandwidth_queue(0)
|
, down_bandwidth_queue(0)
|
||||||
|
, all_time_upload(0)
|
||||||
|
, all_time_download(0)
|
||||||
|
, active_time(0)
|
||||||
|
, seeding_time(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
enum state_t
|
enum state_t
|
||||||
|
@ -240,6 +244,17 @@ namespace libtorrent
|
||||||
|
|
||||||
int up_bandwidth_queue;
|
int up_bandwidth_queue;
|
||||||
int down_bandwidth_queue;
|
int down_bandwidth_queue;
|
||||||
|
|
||||||
|
// number of bytes downloaded since torrent was started
|
||||||
|
// saved and restored from resume data
|
||||||
|
size_type all_time_upload;
|
||||||
|
size_type all_time_download;
|
||||||
|
|
||||||
|
// the number of seconds of being active
|
||||||
|
// and as being a seed, saved and restored
|
||||||
|
// from resume data
|
||||||
|
int active_time;
|
||||||
|
int seeding_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT block_info
|
struct TORRENT_EXPORT block_info
|
||||||
|
|
|
@ -229,8 +229,8 @@ void routing_table::node_failed(node_id const& id)
|
||||||
{
|
{
|
||||||
b.erase(i);
|
b.erase(i);
|
||||||
TORRENT_ASSERT(m_lowest_active_bucket <= bucket_index);
|
TORRENT_ASSERT(m_lowest_active_bucket <= bucket_index);
|
||||||
while (m_buckets[m_lowest_active_bucket].first.empty()
|
while (m_lowest_active_bucket < 160
|
||||||
&& m_lowest_active_bucket < 160)
|
&& m_buckets[m_lowest_active_bucket].first.empty())
|
||||||
{
|
{
|
||||||
++m_lowest_active_bucket;
|
++m_lowest_active_bucket;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1565,6 +1565,13 @@ namespace aux {
|
||||||
m_queued_for_checking.pop_front();
|
m_queued_for_checking.pop_front();
|
||||||
if (!m_queued_for_checking.empty())
|
if (!m_queued_for_checking.empty())
|
||||||
m_queued_for_checking.front()->start_checking();
|
m_queued_for_checking.front()->start_checking();
|
||||||
|
|
||||||
|
if (m_alerts.should_post(alert::info))
|
||||||
|
{
|
||||||
|
m_alerts.post_alert(torrent_checked_alert(
|
||||||
|
t->get_handle()
|
||||||
|
, "torrent finished checking"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_handle session_impl::add_torrent(
|
torrent_handle session_impl::add_torrent(
|
||||||
|
|
|
@ -420,6 +420,8 @@ namespace libtorrent
|
||||||
|
|
||||||
m_state = torrent_status::queued_for_checking;
|
m_state = torrent_status::queued_for_checking;
|
||||||
|
|
||||||
|
read_resume_data(m_resume_data);
|
||||||
|
|
||||||
m_storage->async_check_fastresume(&m_resume_data
|
m_storage->async_check_fastresume(&m_resume_data
|
||||||
, bind(&torrent::on_resume_data_checked
|
, bind(&torrent::on_resume_data_checked
|
||||||
, shared_from_this(), _1, _2));
|
, shared_from_this(), _1, _2));
|
||||||
|
@ -2257,11 +2259,31 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void torrent::read_resume_data(entry const& rd)
|
||||||
|
{
|
||||||
|
entry const* e = 0;
|
||||||
|
e = rd.find_key("total_uploaded");
|
||||||
|
m_total_uploaded = (e != 0 && e->type() == entry::int_t)?e->integer():0;
|
||||||
|
e = rd.find_key("total_downloaded");
|
||||||
|
m_total_downloaded = (e != 0 && e->type() == entry::int_t)?e->integer():0;
|
||||||
|
|
||||||
|
e = rd.find_key("active_time");
|
||||||
|
m_active_time = seconds((e != 0 && e->type() == entry::int_t)?e->integer():0);
|
||||||
|
e = rd.find_key("seeding_time");
|
||||||
|
m_seeding_time = seconds((e != 0 && e->type() == entry::int_t)?e->integer():0);
|
||||||
|
}
|
||||||
|
|
||||||
void torrent::write_resume_data(entry& ret) const
|
void torrent::write_resume_data(entry& ret) const
|
||||||
{
|
{
|
||||||
ret["file-format"] = "libtorrent resume file";
|
ret["file-format"] = "libtorrent resume file";
|
||||||
ret["file-version"] = 1;
|
ret["file-version"] = 1;
|
||||||
|
|
||||||
|
ret["total_uploaded"] = m_total_uploaded;
|
||||||
|
ret["total_downloaded"] = m_total_downloaded;
|
||||||
|
|
||||||
|
ret["active_time"] = total_seconds(m_active_time);
|
||||||
|
ret["seeding_time"] = total_seconds(m_seeding_time);
|
||||||
|
|
||||||
ret["allocation"] = m_storage_mode == storage_mode_sparse?"sparse"
|
ret["allocation"] = m_storage_mode == storage_mode_sparse?"sparse"
|
||||||
:m_storage_mode == storage_mode_allocate?"full":"compact";
|
:m_storage_mode == storage_mode_allocate?"full":"compact";
|
||||||
|
|
||||||
|
@ -3354,6 +3376,10 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time_duration since_last_tick = microsec(tick_interval * 1000000L);
|
||||||
|
if (is_seed()) m_seeding_time += since_last_tick;
|
||||||
|
m_active_time += since_last_tick;
|
||||||
|
|
||||||
// ---- WEB SEEDS ----
|
// ---- WEB SEEDS ----
|
||||||
|
|
||||||
// re-insert urls that are to be retries into the m_web_seeds
|
// re-insert urls that are to be retries into the m_web_seeds
|
||||||
|
@ -3424,6 +3450,8 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
accumulator += m_stat;
|
accumulator += m_stat;
|
||||||
|
m_total_uploaded += m_stat.last_payload_uploaded();
|
||||||
|
m_total_downloaded += m_stat.last_payload_downloaded();
|
||||||
m_stat.second_tick(tick_interval);
|
m_stat.second_tick(tick_interval);
|
||||||
|
|
||||||
m_time_scaler--;
|
m_time_scaler--;
|
||||||
|
@ -3567,6 +3595,12 @@ namespace libtorrent
|
||||||
st.list_seeds = m_policy.num_seeds();
|
st.list_seeds = m_policy.num_seeds();
|
||||||
st.connect_candidates = m_policy.num_connect_candidates();
|
st.connect_candidates = m_policy.num_connect_candidates();
|
||||||
|
|
||||||
|
st.all_time_upload = m_total_uploaded;
|
||||||
|
st.all_time_download = m_total_downloaded;
|
||||||
|
|
||||||
|
st.active_time = total_seconds(m_active_time);
|
||||||
|
st.seeding_time = total_seconds(m_seeding_time);
|
||||||
|
|
||||||
st.storage_mode = m_storage_mode;
|
st.storage_mode = m_storage_mode;
|
||||||
|
|
||||||
st.num_complete = m_complete;
|
st.num_complete = m_complete;
|
||||||
|
|
Loading…
Reference in New Issue