Skip to content

Commit a5e15ae

Browse files
committed
scripted-diff: rename ping members
-BEGIN VERIFY SCRIPT- sed -i 's/fPingQueued/m_ping_queued/g' src/net_processing.cpp sed -i 's/nMinPingUsecTime/m_min_ping_time/g' src/net.* src/net_processing.cpp src/test/net_tests.cpp sed -i 's/nPingNonceSent/m_ping_nonce_sent/g' src/net_processing.cpp sed -i 's/nPingUsecTime/m_last_ping_time/g' src/net.* -END VERIFY SCRIPT-
1 parent 45dcf22 commit a5e15ae

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

src/net.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
601601
stats.minFeeFilter = 0;
602602
}
603603

604-
stats.m_ping_usec = nPingUsecTime;
605-
stats.m_min_ping_usec = nMinPingUsecTime;
604+
stats.m_ping_usec = m_last_ping_time;
605+
stats.m_min_ping_usec = m_min_ping_time;
606606

607607
// Leave string empty if addrLocal invalid (not filled in yet)
608608
CService addrLocalUnlocked = GetAddrLocal();
@@ -824,7 +824,7 @@ size_t CConnman::SocketSendData(CNode& node) const
824824

825825
static bool ReverseCompareNodeMinPingTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
826826
{
827-
return a.nMinPingUsecTime > b.nMinPingUsecTime;
827+
return a.m_min_ping_time > b.m_min_ping_time;
828828
}
829829

830830
static bool ReverseCompareNodeTimeConnected(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
@@ -979,7 +979,7 @@ bool CConnman::AttemptToEvictConnection()
979979
peer_relay_txes = node->m_tx_relay->fRelayTxes;
980980
peer_filter_not_null = node->m_tx_relay->pfilter != nullptr;
981981
}
982-
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->nMinPingUsecTime,
982+
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->m_min_ping_time,
983983
node->nLastBlockTime, node->nLastTXTime,
984984
HasAllDesirableServiceFlags(node->nServices),
985985
peer_relay_txes, peer_filter_not_null, node->nKeyedNetGroup,

src/net.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,11 @@ class CNode
591591
std::atomic<int64_t> nLastTXTime{0};
592592

593593
/** Last measured round-trip time. Used only for RPC/GUI stats/debugging.*/
594-
std::atomic<int64_t> nPingUsecTime{0};
594+
std::atomic<int64_t> m_last_ping_time{0};
595595

596596
/** Lowest measured round-trip time. Used as an inbound peer eviction
597597
* criterium in CConnman::AttemptToEvictConnection. */
598-
std::atomic<int64_t> nMinPingUsecTime{std::numeric_limits<int64_t>::max()};
598+
std::atomic<int64_t> m_min_ping_time{std::numeric_limits<int64_t>::max()};
599599

600600
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);
601601
~CNode();
@@ -717,8 +717,8 @@ class CNode
717717

718718
/** A ping-pong round trip has completed successfully. Update latest and minimum ping times. */
719719
void PongReceived(std::chrono::microseconds ping_time) {
720-
nPingUsecTime = count_microseconds(ping_time);
721-
nMinPingUsecTime = std::min(nMinPingUsecTime.load(), count_microseconds(ping_time));
720+
m_last_ping_time = count_microseconds(ping_time);
721+
m_min_ping_time = std::min(m_min_ping_time.load(), count_microseconds(ping_time));
722722
}
723723

724724
private:
@@ -1253,7 +1253,7 @@ struct NodeEvictionCandidate
12531253
{
12541254
NodeId id;
12551255
int64_t nTimeConnected;
1256-
int64_t nMinPingUsecTime;
1256+
int64_t m_min_ping_time;
12571257
int64_t nLastBlockTime;
12581258
int64_t nLastTXTime;
12591259
bool fRelevantServices;

src/net_processing.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ struct Peer {
220220
std::atomic<int> m_starting_height{-1};
221221

222222
/** The pong reply we're expecting, or 0 if no pong expected. */
223-
std::atomic<uint64_t> nPingNonceSent{0};
223+
std::atomic<uint64_t> m_ping_nonce_sent{0};
224224
/** When the last ping was sent, or 0 if no ping was ever sent */
225225
std::atomic<std::chrono::microseconds> m_ping_start{0us};
226226
/** Whether a ping has been requested by the user */
227-
std::atomic<bool> fPingQueued{false};
227+
std::atomic<bool> m_ping_queued{false};
228228

229229
/** Set of txids to reconsider once their parent transactions have been accepted **/
230230
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
@@ -1108,7 +1108,7 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
11081108
// So, if a ping is taking an unusually long time in flight,
11091109
// the caller can immediately detect that this is happening.
11101110
std::chrono::microseconds ping_wait{0};
1111-
if ((0 != peer->nPingNonceSent) && (0 != peer->m_ping_start.load().count())) {
1111+
if ((0 != peer->m_ping_nonce_sent) && (0 != peer->m_ping_start.load().count())) {
11121112
ping_wait = GetTime<std::chrono::microseconds>() - peer->m_ping_start.load();
11131113
}
11141114

@@ -1655,7 +1655,7 @@ bool static AlreadyHaveBlock(const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED
16551655
void PeerManagerImpl::SendPings()
16561656
{
16571657
LOCK(m_peer_mutex);
1658-
for(auto& it : m_peer_map) it.second->fPingQueued = true;
1658+
for(auto& it : m_peer_map) it.second->m_ping_queued = true;
16591659
}
16601660

16611661
void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman& connman)
@@ -3868,8 +3868,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
38683868
vRecv >> nonce;
38693869

38703870
// Only process pong message if there is an outstanding ping (old ping without nonce should never pong)
3871-
if (peer->nPingNonceSent != 0) {
3872-
if (nonce == peer->nPingNonceSent) {
3871+
if (peer->m_ping_nonce_sent != 0) {
3872+
if (nonce == peer->m_ping_nonce_sent) {
38733873
// Matching pong received, this ping is no longer outstanding
38743874
bPingFinished = true;
38753875
const auto ping_time = ping_end - peer->m_ping_start.load();
@@ -3902,12 +3902,12 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
39023902
LogPrint(BCLog::NET, "pong peer=%d: %s, %x expected, %x received, %u bytes\n",
39033903
pfrom.GetId(),
39043904
sProblem,
3905-
peer->nPingNonceSent,
3905+
peer->m_ping_nonce_sent,
39063906
nonce,
39073907
nAvail);
39083908
}
39093909
if (bPingFinished) {
3910-
peer->nPingNonceSent = 0;
3910+
peer->m_ping_nonce_sent = 0;
39113911
}
39123912
return;
39133913
}
@@ -4327,7 +4327,7 @@ void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer)
43274327
// This means that setmocktime may cause pings to time out.
43284328
auto now = GetTime<std::chrono::microseconds>();
43294329

4330-
if (m_connman.RunInactivityChecks(node_to) && peer.nPingNonceSent &&
4330+
if (m_connman.RunInactivityChecks(node_to) && peer.m_ping_nonce_sent &&
43314331
now > peer.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL}) {
43324332
LogPrint(BCLog::NET, "ping timeout: %fs peer=%d\n", 0.000001 * count_microseconds(now - peer.m_ping_start.load()), peer.m_id);
43334333
node_to.fDisconnect = true;
@@ -4337,12 +4337,12 @@ void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer)
43374337
const CNetMsgMaker msgMaker(node_to.GetCommonVersion());
43384338
bool pingSend = false;
43394339

4340-
if (peer.fPingQueued) {
4340+
if (peer.m_ping_queued) {
43414341
// RPC ping request by user
43424342
pingSend = true;
43434343
}
43444344

4345-
if (peer.nPingNonceSent == 0 && now > peer.m_ping_start.load() + PING_INTERVAL) {
4345+
if (peer.m_ping_nonce_sent == 0 && now > peer.m_ping_start.load() + PING_INTERVAL) {
43464346
// Ping automatically sent as a latency probe & keepalive.
43474347
pingSend = true;
43484348
}
@@ -4352,14 +4352,14 @@ void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer)
43524352
while (nonce == 0) {
43534353
GetRandBytes((unsigned char*)&nonce, sizeof(nonce));
43544354
}
4355-
peer.fPingQueued = false;
4355+
peer.m_ping_queued = false;
43564356
peer.m_ping_start = now;
43574357
if (node_to.GetCommonVersion() > BIP0031_VERSION) {
4358-
peer.nPingNonceSent = nonce;
4358+
peer.m_ping_nonce_sent = nonce;
43594359
m_connman.PushMessage(&node_to, msgMaker.Make(NetMsgType::PING, nonce));
43604360
} else {
43614361
// Peer is too old to support ping command with nonce, pong will never arrive.
4362-
peer.nPingNonceSent = 0;
4362+
peer.m_ping_nonce_sent = 0;
43634363
m_connman.PushMessage(&node_to, msgMaker.Make(NetMsgType::PING));
43644364
}
43654365
}

src/test/net_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(const int n_c
794794
candidates.push_back({
795795
/* id */ id,
796796
/* nTimeConnected */ static_cast<int64_t>(random_context.randrange(100)),
797-
/* nMinPingUsecTime */ static_cast<int64_t>(random_context.randrange(100)),
797+
/* m_min_ping_time */ static_cast<int64_t>(random_context.randrange(100)),
798798
/* nLastBlockTime */ static_cast<int64_t>(random_context.randrange(100)),
799799
/* nLastTXTime */ static_cast<int64_t>(random_context.randrange(100)),
800800
/* fRelevantServices */ random_context.randbool(),
@@ -854,7 +854,7 @@ BOOST_AUTO_TEST_CASE(node_eviction_test)
854854
// from eviction.
855855
BOOST_CHECK(!IsEvicted(
856856
number_of_nodes, [](NodeEvictionCandidate& candidate) {
857-
candidate.nMinPingUsecTime = candidate.id;
857+
candidate.m_min_ping_time = candidate.id;
858858
},
859859
{0, 1, 2, 3, 4, 5, 6, 7}, random_context));
860860

@@ -901,7 +901,7 @@ BOOST_AUTO_TEST_CASE(node_eviction_test)
901901
BOOST_CHECK(!IsEvicted(
902902
number_of_nodes, [number_of_nodes](NodeEvictionCandidate& candidate) {
903903
candidate.nKeyedNetGroup = number_of_nodes - candidate.id; // 4 protected
904-
candidate.nMinPingUsecTime = candidate.id; // 8 protected
904+
candidate.m_min_ping_time = candidate.id; // 8 protected
905905
candidate.nLastTXTime = number_of_nodes - candidate.id; // 4 protected
906906
candidate.nLastBlockTime = number_of_nodes - candidate.id; // 4 protected
907907
},

0 commit comments

Comments
 (0)