diff --git a/src/protocol/peer_connection_base.cc b/src/protocol/peer_connection_base.cc index 9eddbb8..7985ad2 100644 --- a/src/protocol/peer_connection_base.cc +++ b/src/protocol/peer_connection_base.cc @@ -410,6 +410,8 @@ PeerConnectionBase::down_chunk() { return false; } + m_peerInfo->set_last_transfer_down(cachedTime.seconds()); + uint32_t bytesTransfered = 0; BlockTransfer* transfer = m_downloadQueue.transfer(); @@ -642,6 +644,8 @@ PeerConnectionBase::up_chunk() { return false; } + m_peerInfo->set_last_transfer_up(cachedTime.seconds()); + uint32_t bytesTransfered = 0; if (is_encrypted()) { diff --git a/src/torrent/peer/peer_info.cc b/src/torrent/peer/peer_info.cc index 06f9ae8..6bd1db0 100644 --- a/src/torrent/peer/peer_info.cc +++ b/src/torrent/peer/peer_info.cc @@ -54,6 +54,8 @@ PeerInfo::PeerInfo(const sockaddr* address) : m_failedCounter(0), m_transferCounter(0), m_lastConnection(0), + m_lastTransferUp(0), + m_lastTransferDown(0), m_lastHandshake(0), m_listenPort(0), diff --git a/src/torrent/peer/peer_info.h b/src/torrent/peer/peer_info.h index 5a6fe22..584ce86 100644 --- a/src/torrent/peer/peer_info.h +++ b/src/torrent/peer/peer_info.h @@ -100,6 +100,12 @@ public: 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; } @@ -137,6 +143,8 @@ private: 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;