1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
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;
|