diff --git a/bindings/python/src/peer_info.cpp b/bindings/python/src/peer_info.cpp index 9ceeead7a..e054401c1 100644 --- a/bindings/python/src/peer_info.cpp +++ b/bindings/python/src/peer_info.cpp @@ -89,6 +89,7 @@ void bind_peer_info() .def_readonly("send_quota", &peer_info::send_quota) .def_readonly("receive_quota", &peer_info::receive_quota) .def_readonly("rtt", &peer_info::rtt) + .def_readonly("progress", &peer_info::progress) ; // flags diff --git a/docs/manual.rst b/docs/manual.rst index 0fce2d5cd..f351e58c4 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -2687,6 +2687,7 @@ It contains the following fields:: int download_rate_peak; int upload_rate_peak; + float progress; }; The ``flags`` attribute tells you in which state the peer is. It is set to @@ -2906,6 +2907,8 @@ estimated by timing the the tcp ``connect()``. It may be 0 for incoming connecti rates seen on this connection. They are given in bytes per second. This number is reset to 0 on reconnect. +``progress`` is the progress of the peer. + session_settings ================ diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index c85069bff..e28216ce0 100644 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -196,6 +196,9 @@ namespace libtorrent // the highest transfer rates seen for this peer int download_rate_peak; int upload_rate_peak; + + // the peers progress + float progress; }; struct TORRENT_EXPORT peer_list_entry diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 56eaee93d..52f1f2773 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2672,6 +2672,8 @@ namespace libtorrent p.used_receive_buffer = m_recv_pos; p.write_state = m_channel_state[upload_channel]; p.read_state = m_channel_state[download_channel]; + + p.progress = (float)p.pieces.count() / (float)p.pieces.size(); } // allocates a disk buffer of size 'disk_buffer_size' and replaces the