aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-06-21 18:56:19 -0400
committerJohn Newbery <john@johnnewbery.com>2021-02-15 16:15:51 +0000
commit45dcf2266125c65d7f546bdb211a278bd090a284 (patch)
tree384028a852c66190b8f8b1cd5773b90e15880049 /src/net.h
parentdd2646d12c172cb8899669af717c590483a17404 (diff)
downloadbitcoin-45dcf2266125c65d7f546bdb211a278bd090a284.tar.xz
[net processing] Move ping data fields to net processing
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h20
1 files changed, 10 insertions, 10 deletions
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<int64_t> nLastTXTime{0};
- // Ping time measurement:
- // The pong reply we're expecting, or 0 if no pong expected.
- std::atomic<uint64_t> nPingNonceSent{0};
- /** When the last ping was sent, or 0 if no ping was ever sent */
- std::atomic<std::chrono::microseconds> m_ping_start{0us};
- // Last measured round-trip time.
+ /** Last measured round-trip time. Used only for RPC/GUI stats/debugging.*/
std::atomic<int64_t> nPingUsecTime{0};
- // Best measured round-trip time.
+
+ /** Lowest measured round-trip time. Used as an inbound peer eviction
+ * criterium in CConnman::AttemptToEvictConnection. */
std::atomic<int64_t> nMinPingUsecTime{std::numeric_limits<int64_t>::max()};
- // Whether a ping is requested.
- std::atomic<bool> 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;