# Shows how long each peer has been connected, and how much # times has passed since the last data transfer up and down. # # This is informational only, but may be used to decide whether # a peer is good or bad. Index: rtorrent/src/command_helpers.h =================================================================== --- rtorrent/src/command_helpers.h (revision 1110) +++ rtorrent/src/command_helpers.h (working copy) @@ -54,7 +54,7 @@ #define COMMAND_DOWNLOAD_SLOTS_SIZE 150 #define COMMAND_FILE_SLOTS_SIZE 30 #define COMMAND_FILE_ITR_SLOTS_SIZE 10 -#define COMMAND_PEER_SLOTS_SIZE 20 +#define COMMAND_PEER_SLOTS_SIZE 30 #define COMMAND_TRACKER_SLOTS_SIZE 15 #define COMMAND_ANY_SLOTS_SIZE 50 Index: rtorrent/src/command_ui.cc =================================================================== --- rtorrent/src/command_ui.cc (revision 1110) +++ rtorrent/src/command_ui.cc (working copy) @@ -274,6 +274,9 @@ torrent::Object apply_to_elapsed_time(const torrent::Object& rawArgs) { + if (rawArgs.as_value() == 0) + return "--:--:--"; + uint64_t arg = cachedTime.seconds() - rawArgs.as_value(); char buffer[48]; Index: rtorrent/src/display/text_element_value.cc =================================================================== --- rtorrent/src/display/text_element_value.cc (revision 1110) +++ rtorrent/src/display/text_element_value.cc (working copy) @@ -68,7 +68,9 @@ int64_t val = value(target.second); // Transform the value if needed. - if (m_flags & flag_elapsed) + if (m_flags & (flag_elapsed | flag_remaining) && val == 0) + val = -1; + else if (m_flags & flag_elapsed) val = cachedTime.seconds() - val; else if (m_flags & flag_remaining) val = val - cachedTime.seconds(); @@ -100,7 +102,7 @@ first += std::min(std::max(snprintf(first, last - first + 1, "%5.1f TB", (double)val / (int64_t(1) << 40)), 0), last - first + 1); } else if (m_flags & flag_timer) { - if (val == 0) + if (val < 0) first += std::min(std::max(snprintf(first, last - first + 1, "--:--:--"), 0), last - first + 1); else first += std::min(std::max(snprintf(first, last - first + 1, "%2d:%02d:%02d", (int)(val / 3600), (int)((val / 60) % 60), (int)(val % 60)), 0), last - first + 1); Index: rtorrent/src/command_peer.cc =================================================================== --- rtorrent/src/command_peer.cc (revision 1110) +++ rtorrent/src/command_peer.cc (working copy) @@ -139,6 +139,11 @@ ADD_CP_VALUE_UNI("completed_percent", std::ptr_fun(&retrieve_p_completed_percent)); + ADD_CP_VALUE_MEM_UNI("last_connection", &torrent::Peer::peer_info, &torrent::PeerInfo::last_connection); + ADD_CP_VALUE_MEM_UNI("last_transfer", &torrent::Peer::peer_info, &torrent::PeerInfo::last_transfer); + ADD_CP_VALUE_MEM_UNI("last_transfer_up", &torrent::Peer::peer_info, &torrent::PeerInfo::last_transfer_up); + ADD_CP_VALUE_MEM_UNI("last_transfer_down", &torrent::Peer::peer_info, &torrent::PeerInfo::last_transfer_down); + ADD_CP_VALUE_MEM_UNI("up_rate", &torrent::Peer::up_rate, &torrent::Rate::rate); ADD_CP_VALUE_MEM_UNI("up_total", &torrent::Peer::up_rate, &torrent::Rate::total); ADD_CP_VALUE_MEM_UNI("down_rate", &torrent::Peer::down_rate, &torrent::Rate::rate); Index: rtorrent/src/ui/element_peer_list.cc =================================================================== --- rtorrent/src/ui/element_peer_list.cc (revision 1110) +++ rtorrent/src/ui/element_peer_list.cc (working copy) @@ -109,6 +109,7 @@ element->push_column("Options:", te_command("p.get_options_str=")); element->push_column("Connected:", te_command("if=$p.is_incoming=,incoming,outgoing")); element->push_column("Encrypted:", te_command("if=$p.is_encrypted=,yes,$p.is_obfuscated=,handshake,no")); + element->push_column("Time:", te_command("cat=Connected\\ ,$to_elapsed_time=$p.get_last_connection=,\\ \\ Idle\\ ,$to_elapsed_time=$p.get_last_transfer_up=,\\ up\\ \\ ,$to_elapsed_time=$p.get_last_transfer_down=,\\ down")); element->push_back(""); element->push_column("Snubbed:", te_command("if=$p.is_snubbed=,yes,no")); Index: libtorrent/src/torrent/peer/peer_info.cc =================================================================== --- libtorrent/src/torrent/peer/peer_info.cc (revision 1110) +++ libtorrent/src/torrent/peer/peer_info.cc (working copy) @@ -54,6 +54,8 @@ m_failedCounter(0), m_transferCounter(0), m_lastConnection(0), + m_lastTransferUp(0), + m_lastTransferDown(0), m_lastHandshake(0), m_listenPort(0), Index: libtorrent/src/torrent/peer/peer_info.h =================================================================== --- libtorrent/src/torrent/peer/peer_info.h (revision 1110) +++ libtorrent/src/torrent/peer/peer_info.h (working copy) @@ -85,6 +85,12 @@ uint32_t last_connection() const { return m_lastConnection; } void set_last_connection(uint32_t tvsec) { m_lastConnection = tvsec; } + uint32_t last_transfer_up() const { return m_lastTransferUp; } + uint32_t last_transfer_down() const { return m_lastTransferDown; } + uint32_t last_transfer() const { return std::max(m_lastTransferUp, m_lastTransferDown); } + void set_last_transfer_up(uint32_t tvsec) { m_lastTransferUp = tvsec; } + void set_last_transfer_down(uint32_t tvsec){ m_lastTransferDown = tvsec; } + uint32_t last_handshake() const { return m_lastHandshake; } void set_last_handshake(uint32_t tvsec) { m_lastHandshake = tvsec; } @@ -121,6 +127,8 @@ uint32_t m_failedCounter; uint32_t m_transferCounter; uint32_t m_lastConnection; + uint32_t m_lastTransferUp; + uint32_t m_lastTransferDown; uint32_t m_lastHandshake; uint16_t m_listenPort; Index: libtorrent/src/protocol/peer_connection_base.cc =================================================================== --- libtorrent/src/protocol/peer_connection_base.cc (revision 1110) +++ libtorrent/src/protocol/peer_connection_base.cc (working copy) @@ -404,6 +404,8 @@ return false; } + m_peerInfo->set_last_transfer_down(cachedTime.seconds()); + uint32_t bytesTransfered = 0; BlockTransfer* transfer = m_downloadQueue.transfer(); @@ -632,6 +634,8 @@ return false; } + m_peerInfo->set_last_transfer_up(cachedTime.seconds()); + uint32_t bytesTransfered = 0; if (is_encrypted()) {