Skip to content

Commit fad9438

Browse files
author
MarcoFalke
committed
scripted-diff: Rename touched member variables
-BEGIN VERIFY SCRIPT- ren() { sed -i "s/\<$1\>/$2/g" $( git grep -l "$1" ./src/ ) ; } ren nLastBlockTime m_last_block_time ren nLastTXTime m_last_tx_time ren nTimeConnected m_connected -END VERIFY SCRIPT-
1 parent fa663a4 commit fad9438

File tree

10 files changed

+85
-85
lines changed

10 files changed

+85
-85
lines changed

src/bench/peer_eviction.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void EvictionProtection0Networks250Candidates(benchmark::Bench& bench)
4242
bench,
4343
250 /* num_candidates */,
4444
[](NodeEvictionCandidate& c) {
45-
c.nTimeConnected = std::chrono::seconds{c.id};
45+
c.m_connected = std::chrono::seconds{c.id};
4646
c.m_network = NET_IPV4;
4747
});
4848
}
@@ -53,7 +53,7 @@ static void EvictionProtection1Networks250Candidates(benchmark::Bench& bench)
5353
bench,
5454
250 /* num_candidates */,
5555
[](NodeEvictionCandidate& c) {
56-
c.nTimeConnected = std::chrono::seconds{c.id};
56+
c.m_connected = std::chrono::seconds{c.id};
5757
c.m_is_local = false;
5858
if (c.id >= 130 && c.id < 240) { // 110 Tor
5959
c.m_network = NET_ONION;
@@ -69,7 +69,7 @@ static void EvictionProtection2Networks250Candidates(benchmark::Bench& bench)
6969
bench,
7070
250 /* num_candidates */,
7171
[](NodeEvictionCandidate& c) {
72-
c.nTimeConnected = std::chrono::seconds{c.id};
72+
c.m_connected = std::chrono::seconds{c.id};
7373
c.m_is_local = false;
7474
if (c.id >= 90 && c.id < 160) { // 70 Tor
7575
c.m_network = NET_ONION;
@@ -87,7 +87,7 @@ static void EvictionProtection3Networks050Candidates(benchmark::Bench& bench)
8787
bench,
8888
50 /* num_candidates */,
8989
[](NodeEvictionCandidate& c) {
90-
c.nTimeConnected = std::chrono::seconds{c.id};
90+
c.m_connected = std::chrono::seconds{c.id};
9191
c.m_is_local = (c.id == 28 || c.id == 47); // 2 localhost
9292
if (c.id >= 30 && c.id < 47) { // 17 I2P
9393
c.m_network = NET_I2P;
@@ -105,7 +105,7 @@ static void EvictionProtection3Networks100Candidates(benchmark::Bench& bench)
105105
bench,
106106
100 /* num_candidates */,
107107
[](NodeEvictionCandidate& c) {
108-
c.nTimeConnected = std::chrono::seconds{c.id};
108+
c.m_connected = std::chrono::seconds{c.id};
109109
c.m_is_local = (c.id >= 55 && c.id < 60); // 5 localhost
110110
if (c.id >= 70 && c.id < 80) { // 10 I2P
111111
c.m_network = NET_I2P;
@@ -123,7 +123,7 @@ static void EvictionProtection3Networks250Candidates(benchmark::Bench& bench)
123123
bench,
124124
250 /* num_candidates */,
125125
[](NodeEvictionCandidate& c) {
126-
c.nTimeConnected = std::chrono::seconds{c.id};
126+
c.m_connected = std::chrono::seconds{c.id};
127127
c.m_is_local = (c.id >= 140 && c.id < 160); // 20 localhost
128128
if (c.id >= 170 && c.id < 180) { // 10 I2P
129129
c.m_network = NET_I2P;

src/net.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,9 @@ void CNode::CopyStats(CNodeStats& stats)
588588
}
589589
X(m_last_send);
590590
X(m_last_recv);
591-
X(nLastTXTime);
592-
X(nLastBlockTime);
593-
X(nTimeConnected);
591+
X(m_last_tx_time);
592+
X(m_last_block_time);
593+
X(m_connected);
594594
X(nTimeOffset);
595595
X(m_addr_name);
596596
X(nVersion);
@@ -847,7 +847,7 @@ static bool ReverseCompareNodeMinPingTime(const NodeEvictionCandidate &a, const
847847

848848
static bool ReverseCompareNodeTimeConnected(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
849849
{
850-
return a.nTimeConnected > b.nTimeConnected;
850+
return a.m_connected > b.m_connected;
851851
}
852852

853853
static bool CompareNetGroupKeyed(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) {
@@ -857,27 +857,27 @@ static bool CompareNetGroupKeyed(const NodeEvictionCandidate &a, const NodeEvict
857857
static bool CompareNodeBlockTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
858858
{
859859
// There is a fall-through here because it is common for a node to have many peers which have not yet relayed a block.
860-
if (a.nLastBlockTime != b.nLastBlockTime) return a.nLastBlockTime < b.nLastBlockTime;
860+
if (a.m_last_block_time != b.m_last_block_time) return a.m_last_block_time < b.m_last_block_time;
861861
if (a.fRelevantServices != b.fRelevantServices) return b.fRelevantServices;
862-
return a.nTimeConnected > b.nTimeConnected;
862+
return a.m_connected > b.m_connected;
863863
}
864864

865865
static bool CompareNodeTXTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
866866
{
867867
// There is a fall-through here because it is common for a node to have more than a few peers that have not yet relayed txn.
868-
if (a.nLastTXTime != b.nLastTXTime) return a.nLastTXTime < b.nLastTXTime;
868+
if (a.m_last_tx_time != b.m_last_tx_time) return a.m_last_tx_time < b.m_last_tx_time;
869869
if (a.fRelayTxes != b.fRelayTxes) return b.fRelayTxes;
870870
if (a.fBloomFilter != b.fBloomFilter) return a.fBloomFilter;
871-
return a.nTimeConnected > b.nTimeConnected;
871+
return a.m_connected > b.m_connected;
872872
}
873873

874874
// Pick out the potential block-relay only peers, and sort them by last block time.
875875
static bool CompareNodeBlockRelayOnlyTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
876876
{
877877
if (a.fRelayTxes != b.fRelayTxes) return a.fRelayTxes;
878-
if (a.nLastBlockTime != b.nLastBlockTime) return a.nLastBlockTime < b.nLastBlockTime;
878+
if (a.m_last_block_time != b.m_last_block_time) return a.m_last_block_time < b.m_last_block_time;
879879
if (a.fRelevantServices != b.fRelevantServices) return b.fRelevantServices;
880-
return a.nTimeConnected > b.nTimeConnected;
880+
return a.m_connected > b.m_connected;
881881
}
882882

883883
/**
@@ -896,7 +896,7 @@ struct CompareNodeNetworkTime {
896896
{
897897
if (m_is_local && a.m_is_local != b.m_is_local) return b.m_is_local;
898898
if ((a.m_network == m_network) != (b.m_network == m_network)) return b.m_network == m_network;
899-
return a.nTimeConnected > b.nTimeConnected;
899+
return a.m_connected > b.m_connected;
900900
};
901901
};
902902

@@ -1028,7 +1028,7 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& evicti
10281028
for (const NodeEvictionCandidate &node : vEvictionCandidates) {
10291029
std::vector<NodeEvictionCandidate> &group = mapNetGroupNodes[node.nKeyedNetGroup];
10301030
group.push_back(node);
1031-
const auto grouptime{group[0].nTimeConnected};
1031+
const auto grouptime{group[0].m_connected};
10321032

10331033
if (group.size() > nMostConnections || (group.size() == nMostConnections && grouptime > nMostConnectionsTime)) {
10341034
nMostConnections = group.size();
@@ -1072,8 +1072,8 @@ bool CConnman::AttemptToEvictConnection()
10721072
peer_relay_txes = node->m_tx_relay->fRelayTxes;
10731073
peer_filter_not_null = node->m_tx_relay->pfilter != nullptr;
10741074
}
1075-
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->m_min_ping_time,
1076-
node->nLastBlockTime, node->nLastTXTime,
1075+
NodeEvictionCandidate candidate = {node->GetId(), node->m_connected, node->m_min_ping_time,
1076+
node->m_last_block_time, node->m_last_tx_time,
10771077
HasAllDesirableServiceFlags(node->nServices),
10781078
peer_relay_txes, peer_filter_not_null, node->nKeyedNetGroup,
10791079
node->m_prefer_evict, node->addr.IsLocal(),
@@ -1320,7 +1320,7 @@ void CConnman::NotifyNumConnectionsChanged()
13201320

13211321
bool CConnman::ShouldRunInactivityChecks(const CNode& node, std::chrono::seconds now) const
13221322
{
1323-
return node.nTimeConnected + m_peer_connect_timeout < now;
1323+
return node.m_connected + m_peer_connect_timeout < now;
13241324
}
13251325

13261326
bool CConnman::InactivityCheck(const CNode& node) const
@@ -2975,7 +2975,7 @@ ServiceFlags CConnman::GetLocalServices() const
29752975
unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; }
29762976

29772977
CNode::CNode(NodeId idIn, 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)
2978-
: nTimeConnected{GetTime<std::chrono::seconds>()},
2978+
: m_connected{GetTime<std::chrono::seconds>()},
29792979
addr(addrIn),
29802980
addrBind(addrBindIn),
29812981
m_addr_name{addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn},

src/net.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ class CNodeStats
243243
bool fRelayTxes;
244244
std::chrono::seconds m_last_send;
245245
std::chrono::seconds m_last_recv;
246-
std::chrono::seconds nLastTXTime;
247-
std::chrono::seconds nLastBlockTime;
248-
std::chrono::seconds nTimeConnected;
246+
std::chrono::seconds m_last_tx_time;
247+
std::chrono::seconds m_last_block_time;
248+
std::chrono::seconds m_connected;
249249
int64_t nTimeOffset;
250250
std::string m_addr_name;
251251
int nVersion;
@@ -423,7 +423,7 @@ class CNode
423423
std::atomic<std::chrono::seconds> m_last_send{0s};
424424
std::atomic<std::chrono::seconds> m_last_recv{0s};
425425
//! Unix epoch time at peer connection
426-
const std::chrono::seconds nTimeConnected;
426+
const std::chrono::seconds m_connected;
427427
std::atomic<int64_t> nTimeOffset{0};
428428
// Address of this peer
429429
const CAddress addr;
@@ -562,13 +562,13 @@ class CNode
562562
* preliminary validity checks and was saved to disk, even if we don't
563563
* connect the block or it eventually fails connection. Used as an inbound
564564
* peer eviction criterium in CConnman::AttemptToEvictConnection. */
565-
std::atomic<std::chrono::seconds> nLastBlockTime{0s};
565+
std::atomic<std::chrono::seconds> m_last_block_time{0s};
566566

567567
/** UNIX epoch time of the last transaction received from this peer that we
568568
* had not yet seen (e.g. not already received from another peer) and that
569569
* was accepted into our mempool. Used as an inbound peer eviction criterium
570570
* in CConnman::AttemptToEvictConnection. */
571-
std::atomic<std::chrono::seconds> nLastTXTime{0s};
571+
std::atomic<std::chrono::seconds> m_last_tx_time{0s};
572572

573573
/** Last measured round-trip time. Used only for RPC/GUI stats/debugging.*/
574574
std::atomic<std::chrono::microseconds> m_last_ping_time{0us};
@@ -1274,10 +1274,10 @@ void CaptureMessage(const CAddress& addr, const std::string& msg_type, const Spa
12741274
struct NodeEvictionCandidate
12751275
{
12761276
NodeId id;
1277-
std::chrono::seconds nTimeConnected;
1277+
std::chrono::seconds m_connected;
12781278
std::chrono::microseconds m_min_ping_time;
1279-
std::chrono::seconds nLastBlockTime;
1280-
std::chrono::seconds nLastTXTime;
1279+
std::chrono::seconds m_last_block_time;
1280+
std::chrono::seconds m_last_tx_time;
12811281
bool fRelevantServices;
12821282
bool fRelayTxes;
12831283
bool fBloomFilter;

src/net_processing.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,7 +2511,7 @@ void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlo
25112511
bool new_block{false};
25122512
m_chainman.ProcessNewBlock(m_chainparams, block, force_processing, &new_block);
25132513
if (new_block) {
2514-
node.nLastBlockTime = GetTime<std::chrono::seconds>();
2514+
node.m_last_block_time = GetTime<std::chrono::seconds>();
25152515
} else {
25162516
LOCK(cs_main);
25172517
mapBlockSource.erase(block->GetHash());
@@ -3314,7 +3314,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
33143314
_RelayTransaction(tx.GetHash(), tx.GetWitnessHash());
33153315
m_orphanage.AddChildrenToWorkSet(tx, peer->m_orphan_work_set);
33163316

3317-
pfrom.nLastTXTime = GetTime<std::chrono::seconds>();
3317+
pfrom.m_last_tx_time = GetTime<std::chrono::seconds>();
33183318

33193319
LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (poolsz %u txn, %u kB)\n",
33203320
pfrom.GetId(),
@@ -4244,7 +4244,7 @@ void PeerManagerImpl::EvictExtraOutboundPeers(std::chrono::seconds now)
42444244
if (pnode->GetId() > youngest_peer.first) {
42454245
next_youngest_peer = youngest_peer;
42464246
youngest_peer.first = pnode->GetId();
4247-
youngest_peer.second = pnode->nLastBlockTime;
4247+
youngest_peer.second = pnode->m_last_block_time;
42484248
}
42494249
});
42504250
NodeId to_disconnect = youngest_peer.first;
@@ -4262,14 +4262,14 @@ void PeerManagerImpl::EvictExtraOutboundPeers(std::chrono::seconds now)
42624262
// valid headers chain with at least as much work as our tip.
42634263
CNodeState *node_state = State(pnode->GetId());
42644264
if (node_state == nullptr ||
4265-
(now - pnode->nTimeConnected >= MINIMUM_CONNECT_TIME && node_state->nBlocksInFlight == 0)) {
4265+
(now - pnode->m_connected >= MINIMUM_CONNECT_TIME && node_state->nBlocksInFlight == 0)) {
42664266
pnode->fDisconnect = true;
42674267
LogPrint(BCLog::NET, "disconnecting extra block-relay-only peer=%d (last block received at time %d)\n",
4268-
pnode->GetId(), count_seconds(pnode->nLastBlockTime));
4268+
pnode->GetId(), count_seconds(pnode->m_last_block_time));
42694269
return true;
42704270
} else {
42714271
LogPrint(BCLog::NET, "keeping block-relay-only peer=%d chosen for eviction (connect time: %d, blocks_in_flight: %d)\n",
4272-
pnode->GetId(), count_seconds(pnode->nTimeConnected), node_state->nBlocksInFlight);
4272+
pnode->GetId(), count_seconds(pnode->m_connected), node_state->nBlocksInFlight);
42734273
}
42744274
return false;
42754275
});
@@ -4309,13 +4309,13 @@ void PeerManagerImpl::EvictExtraOutboundPeers(std::chrono::seconds now)
43094309
// Also don't disconnect any peer we're trying to download a
43104310
// block from.
43114311
CNodeState &state = *State(pnode->GetId());
4312-
if (now - pnode->nTimeConnected > MINIMUM_CONNECT_TIME && state.nBlocksInFlight == 0) {
4312+
if (now - pnode->m_connected > MINIMUM_CONNECT_TIME && state.nBlocksInFlight == 0) {
43134313
LogPrint(BCLog::NET, "disconnecting extra outbound peer=%d (last block announcement received at time %d)\n", pnode->GetId(), oldest_block_announcement);
43144314
pnode->fDisconnect = true;
43154315
return true;
43164316
} else {
43174317
LogPrint(BCLog::NET, "keeping outbound peer=%d chosen for eviction (connect time: %d, blocks_in_flight: %d)\n",
4318-
pnode->GetId(), count_seconds(pnode->nTimeConnected), state.nBlocksInFlight);
4318+
pnode->GetId(), count_seconds(pnode->m_connected), state.nBlocksInFlight);
43194319
return false;
43204320
}
43214321
});
@@ -4567,7 +4567,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
45674567

45684568
const auto current_time = GetTime<std::chrono::microseconds>();
45694569

4570-
if (pto->IsAddrFetchConn() && current_time - pto->nTimeConnected > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
4570+
if (pto->IsAddrFetchConn() && current_time - pto->m_connected > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
45714571
LogPrint(BCLog::NET, "addrfetch connection timeout; disconnecting peer=%d\n", pto->GetId());
45724572
pto->fDisconnect = true;
45734573
return true;

src/qt/rpcconsole.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,9 @@ void RPCConsole::updateDetailWidget()
11731173
if (bip152_hb_settings.isEmpty()) bip152_hb_settings = ts.no;
11741174
ui->peerHighBandwidth->setText(bip152_hb_settings);
11751175
const auto time_now{GetTime<std::chrono::seconds>()};
1176-
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected));
1177-
ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.nLastBlockTime));
1178-
ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.nLastTXTime));
1176+
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.m_connected));
1177+
ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.m_last_block_time));
1178+
ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.m_last_tx_time));
11791179
ui->peerLastSend->setText(TimeDurationField(time_now, stats->nodeStats.m_last_send));
11801180
ui->peerLastRecv->setText(TimeDurationField(time_now, stats->nodeStats.m_last_recv));
11811181
ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));

src/rpc/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ static RPCHelpMan getpeerinfo()
198198
obj.pushKV("relaytxes", stats.fRelayTxes);
199199
obj.pushKV("lastsend", count_seconds(stats.m_last_send));
200200
obj.pushKV("lastrecv", count_seconds(stats.m_last_recv));
201-
obj.pushKV("last_transaction", count_seconds(stats.nLastTXTime));
202-
obj.pushKV("last_block", count_seconds(stats.nLastBlockTime));
201+
obj.pushKV("last_transaction", count_seconds(stats.m_last_tx_time));
202+
obj.pushKV("last_block", count_seconds(stats.m_last_block_time));
203203
obj.pushKV("bytessent", stats.nSendBytes);
204204
obj.pushKV("bytesrecv", stats.nRecvBytes);
205-
obj.pushKV("conntime", count_seconds(stats.nTimeConnected));
205+
obj.pushKV("conntime", count_seconds(stats.m_connected));
206206
obj.pushKV("timeoffset", stats.nTimeOffset);
207207
if (stats.m_last_ping_time > 0us) {
208208
obj.pushKV("pingtime", CountSecondsDouble(stats.m_last_ping_time));

src/test/denialofservice_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(block_relay_only_eviction)
242242
// Update the last block time for the extra peer,
243243
// and check that the next youngest peer gets evicted.
244244
vNodes.back()->fDisconnect = false;
245-
vNodes.back()->nLastBlockTime = GetTime<std::chrono::seconds>();
245+
vNodes.back()->m_last_block_time = GetTime<std::chrono::seconds>();
246246

247247
peerLogic->CheckForStaleTipAndEvictPeers();
248248
for (int i = 0; i < max_outbound_block_relay - 1; ++i) {

src/test/fuzz/node_eviction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ FUZZ_TARGET(node_eviction)
2121
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
2222
eviction_candidates.push_back({
2323
/*id=*/fuzzed_data_provider.ConsumeIntegral<NodeId>(),
24-
/*nTimeConnected=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
24+
/*m_connected=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
2525
/*m_min_ping_time=*/std::chrono::microseconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
26-
/*nLastBlockTime=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
27-
/*nLastTXTime=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
26+
/*m_last_block_time=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
27+
/*m_last_tx_time=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()},
2828
/*fRelevantServices=*/fuzzed_data_provider.ConsumeBool(),
2929
/*fRelayTxes=*/fuzzed_data_provider.ConsumeBool(),
3030
/*fBloomFilter=*/fuzzed_data_provider.ConsumeBool(),

0 commit comments

Comments
 (0)