forked from premiere/premiere-libtorrent
added active_time, seeding_time, all_time_upload and all_time_download to torrent_status. Also updated docs with some missing entries in torrent_status
This commit is contained in:
parent
1724b1eb75
commit
755e50bb12
|
@ -2274,7 +2274,16 @@ struct torrent_status
|
|||
int uploads_limit;
|
||||
int connections_limit;
|
||||
|
||||
bool compact_mode;
|
||||
storage_mode_t storage_mode;
|
||||
|
||||
int up_bandwidth_queue;
|
||||
int down_bandwidth_queue;
|
||||
|
||||
size_type all_time_upload;
|
||||
size_type all_time_download;
|
||||
|
||||
int active_time;
|
||||
int seeding_time;
|
||||
};
|
||||
</pre>
|
||||
<p><tt class="docutils literal"><span class="pre">progress</span></tt> is a value in the range [0, 1], that represents the progress of the
|
||||
|
@ -2411,8 +2420,23 @@ half-open connections that hasn't completed the bittorrent handshake yet. This i
|
|||
always <= <tt class="docutils literal"><span class="pre">num_peers</span></tt>.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">uploads_limit</span></tt> is the set limit of upload slots (unchoked peers) for this torrent.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">connections_limit</span></tt> is the set limit of number of connections for this torrent.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">compact_mode</span></tt> is true if this torrent was started with compact allocation mode
|
||||
for its storage. False means it was started in full allocation mode.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">storage_mode</span></tt> is one of <tt class="docutils literal"><span class="pre">storage_mode_allocate</span></tt>, <tt class="docutils literal"><span class="pre">storage_mode_sparse</span></tt> or
|
||||
<tt class="docutils literal"><span class="pre">storage_mode_compact</span></tt>. Identifies which storage mode this torrent is being saved
|
||||
with. See <a class="reference internal" href="#storage-allocation">Storage allocation</a>.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">up_bandwidth_queue</span></tt> and <tt class="docutils literal"><span class="pre">down_bandwidth_queue</span></tt> are the number of peers in this
|
||||
torrent that are waiting for more bandwidth quota from the torrent rate limiter.
|
||||
This can determine if the rate you get from this torrent is bound by the torrents
|
||||
limit or not. If there is no limit set on this torrent, the peers might still be
|
||||
waiting for bandwidth quota from the global limiter, but then they are counted in
|
||||
the <tt class="docutils literal"><span class="pre">session_status</span></tt> object.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">all_time_upload</span></tt> and <tt class="docutils literal"><span class="pre">all_time_download</span></tt> are accumulated upload and download
|
||||
byte counters. They are saved in and restored from resume data to keep totals
|
||||
across sessions.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">active_time</span></tt> and <tt class="docutils literal"><span class="pre">seeding_time</span></tt> are second counters. They keep track of the
|
||||
number of seconds this torrent has been active (not paused) and the number of
|
||||
seconds it has been active while being a seed. <tt class="docutils literal"><span class="pre">seeding_time</span></tt> should be >=
|
||||
<tt class="docutils literal"><span class="pre">active_time</span></tt> They are saved in and restored from resume data, to keep totals
|
||||
across sessions.</p>
|
||||
</div>
|
||||
<div class="section" id="peer-info">
|
||||
<h1>peer_info</h1>
|
||||
|
|
|
@ -2255,7 +2255,16 @@ It contains the following fields::
|
|||
int uploads_limit;
|
||||
int connections_limit;
|
||||
|
||||
bool compact_mode;
|
||||
storage_mode_t storage_mode;
|
||||
|
||||
int up_bandwidth_queue;
|
||||
int down_bandwidth_queue;
|
||||
|
||||
size_type all_time_upload;
|
||||
size_type all_time_download;
|
||||
|
||||
int active_time;
|
||||
int seeding_time;
|
||||
};
|
||||
|
||||
``progress`` is a value in the range [0, 1], that represents the progress of the
|
||||
|
@ -2406,8 +2415,26 @@ always <= ``num_peers``.
|
|||
|
||||
``connections_limit`` is the set limit of number of connections for this torrent.
|
||||
|
||||
``compact_mode`` is true if this torrent was started with compact allocation mode
|
||||
for its storage. False means it was started in full allocation mode.
|
||||
``storage_mode`` is one of ``storage_mode_allocate``, ``storage_mode_sparse`` or
|
||||
``storage_mode_compact``. Identifies which storage mode this torrent is being saved
|
||||
with. See `Storage allocation`_.
|
||||
|
||||
``up_bandwidth_queue`` and ``down_bandwidth_queue`` are the number of peers in this
|
||||
torrent that are waiting for more bandwidth quota from the torrent rate limiter.
|
||||
This can determine if the rate you get from this torrent is bound by the torrents
|
||||
limit or not. If there is no limit set on this torrent, the peers might still be
|
||||
waiting for bandwidth quota from the global limiter, but then they are counted in
|
||||
the ``session_status`` object.
|
||||
|
||||
``all_time_upload`` and ``all_time_download`` are accumulated upload and download
|
||||
byte counters. They are saved in and restored from resume data to keep totals
|
||||
across sessions.
|
||||
|
||||
``active_time`` and ``seeding_time`` are second counters. They keep track of the
|
||||
number of seconds this torrent has been active (not paused) and the number of
|
||||
seconds it has been active while being a seed. ``seeding_time`` should be >=
|
||||
``active_time`` They are saved in and restored from resume data, to keep totals
|
||||
across sessions.
|
||||
|
||||
peer_info
|
||||
=========
|
||||
|
|
|
@ -1245,7 +1245,9 @@ int main(int ac, char* av[])
|
|||
out << "upload: " << esc("31") << (s.upload_rate > 0 ? add_suffix(s.upload_rate) + "/s ": " ") << esc("0")
|
||||
<< "(" << esc("31") << add_suffix(s.total_upload) << esc("0") << ") "
|
||||
<< "ratio: " << ratio(s.total_payload_download, s.total_payload_upload)
|
||||
<< " bw queue: (" << s.up_bandwidth_queue << " | " << s.down_bandwidth_queue << ")\n";
|
||||
<< " bw queue: (" << s.up_bandwidth_queue << " | " << s.down_bandwidth_queue << ") "
|
||||
"a: " << s.active_time << " s: " << s.seeding_time
|
||||
<< " all-time (Rx :" << s.all_time_download << " Tx: " << s.all_time_upload << ")\n";
|
||||
if (s.state != torrent_status::seeding)
|
||||
{
|
||||
boost::posix_time::time_duration t = s.next_announce;
|
||||
|
|
|
@ -138,6 +138,9 @@ namespace libtorrent
|
|||
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:
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -99,6 +99,7 @@ namespace libtorrent
|
|||
time_duration operator/(int rhs) const { return time_duration(diff / rhs); }
|
||||
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) { return time_duration(diff + c.diff); }
|
||||
boost::int64_t diff;
|
||||
};
|
||||
|
|
|
@ -518,6 +518,7 @@ namespace libtorrent
|
|||
torrent_handle get_handle();
|
||||
|
||||
void write_resume_data(entry& rd) const;
|
||||
void read_resume_data(entry const& rd);
|
||||
|
||||
// LOGGING
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
|
@ -838,6 +839,23 @@ namespace libtorrent
|
|||
int m_deficit_counter;
|
||||
|
||||
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
|
||||
|
|
|
@ -114,6 +114,10 @@ namespace libtorrent
|
|||
, storage_mode(storage_mode_sparse)
|
||||
, up_bandwidth_queue(0)
|
||||
, down_bandwidth_queue(0)
|
||||
, all_time_upload(0)
|
||||
, all_time_download(0)
|
||||
, active_time(0)
|
||||
, seeding_time(0)
|
||||
{}
|
||||
|
||||
enum state_t
|
||||
|
@ -240,6 +244,17 @@ namespace libtorrent
|
|||
|
||||
int up_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
|
||||
|
|
|
@ -420,6 +420,8 @@ namespace libtorrent
|
|||
|
||||
m_state = torrent_status::queued_for_checking;
|
||||
|
||||
read_resume_data(m_resume_data);
|
||||
|
||||
m_storage->async_check_fastresume(&m_resume_data
|
||||
, bind(&torrent::on_resume_data_checked
|
||||
, shared_from_this(), _1, _2));
|
||||
|
@ -2257,11 +2259,31 @@ namespace libtorrent
|
|||
}
|
||||
#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
|
||||
{
|
||||
ret["file-format"] = "libtorrent resume file";
|
||||
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"
|
||||
:m_storage_mode == storage_mode_allocate?"full":"compact";
|
||||
|
||||
|
@ -3354,6 +3376,10 @@ namespace libtorrent
|
|||
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 ----
|
||||
|
||||
// re-insert urls that are to be retries into the m_web_seeds
|
||||
|
@ -3424,6 +3450,8 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
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_time_scaler--;
|
||||
|
@ -3567,6 +3595,12 @@ namespace libtorrent
|
|||
st.list_seeds = m_policy.num_seeds();
|
||||
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.num_complete = m_complete;
|
||||
|
|
Loading…
Reference in New Issue