P2PServer: use high_resolution_clock for ping time

This commit is contained in:
SChernykh 2022-02-21 18:46:53 +01:00
parent f082488e4b
commit 9a09d15bea
2 changed files with 3 additions and 3 deletions

View file

@ -303,7 +303,7 @@ void P2PServer::update_peer_list()
}); });
if (result) { if (result) {
client->m_lastPeerListRequestTime = std::chrono::system_clock::now(); client->m_lastPeerListRequestTime = std::chrono::high_resolution_clock::now();
++client->m_peerListPendingRequests; ++client->m_peerListPendingRequests;
} }
} }
@ -1255,7 +1255,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
bytes_read = 2u + num_peers * 19u; bytes_read = 2u + num_peers * 19u;
using namespace std::chrono; using namespace std::chrono;
m_pingTime = duration_cast<milliseconds>(system_clock::now() - m_lastPeerListRequestTime).count(); m_pingTime = duration_cast<milliseconds>(high_resolution_clock::now() - m_lastPeerListRequestTime).count();
--m_peerListPendingRequests; --m_peerListPendingRequests;
if (!on_peer_list_response(buf + 1)) { if (!on_peer_list_response(buf + 1)) {

View file

@ -112,7 +112,7 @@ public:
time_t m_prevIncomingPeerListRequest; time_t m_prevIncomingPeerListRequest;
uint64_t m_nextOutgoingPeerListRequest; uint64_t m_nextOutgoingPeerListRequest;
std::chrono::system_clock::time_point m_lastPeerListRequestTime; std::chrono::high_resolution_clock::time_point m_lastPeerListRequestTime;
int m_peerListPendingRequests; int m_peerListPendingRequests;
int64_t m_pingTime; int64_t m_pingTime;