From 45dcf2266125c65d7f546bdb211a278bd090a284 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Sun, 21 Jun 2020 18:56:19 -0400 Subject: [net processing] Move ping data fields to net processing --- src/net.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/net.h') diff --git a/src/net.h b/src/net.h index 425371f3d5..c6c62c29e7 100644 --- a/src/net.h +++ b/src/net.h @@ -260,7 +260,6 @@ public: mapMsgCmdSize mapRecvBytesPerMsgCmd; NetPermissionFlags m_permissionFlags; int64_t m_ping_usec; - int64_t m_ping_wait_usec; int64_t m_min_ping_usec; CAmount minFeeFilter; // Our address, as reported by the peer @@ -591,17 +590,12 @@ public: * in CConnman::AttemptToEvictConnection. */ std::atomic nLastTXTime{0}; - // Ping time measurement: - // The pong reply we're expecting, or 0 if no pong expected. - std::atomic nPingNonceSent{0}; - /** When the last ping was sent, or 0 if no ping was ever sent */ - std::atomic m_ping_start{0us}; - // Last measured round-trip time. + /** Last measured round-trip time. Used only for RPC/GUI stats/debugging.*/ std::atomic nPingUsecTime{0}; - // Best measured round-trip time. + + /** Lowest measured round-trip time. Used as an inbound peer eviction + * criterium in CConnman::AttemptToEvictConnection. */ std::atomic nMinPingUsecTime{std::numeric_limits::max()}; - // Whether a ping is requested. - std::atomic fPingQueued{false}; CNode(NodeId id, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in, bool inbound_onion); ~CNode(); @@ -721,6 +715,12 @@ public: std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); } + /** A ping-pong round trip has completed successfully. Update latest and minimum ping times. */ + void PongReceived(std::chrono::microseconds ping_time) { + nPingUsecTime = count_microseconds(ping_time); + nMinPingUsecTime = std::min(nMinPingUsecTime.load(), count_microseconds(ping_time)); + } + private: const NodeId id; const uint64_t nLocalHostNonce; -- cgit v1.2.3