Skip to content

Commit a694ef7

Browse files
jnewberyFabcien
authored andcommitted
[net processing] Rename nStartingHeight to m_starting_height
Summary: ``` Not done as a scripted diff to avoid misnaming the local variable in ProcessMessage(). ``` Partial backport of [[ bitcoin/bitcoin#19829 | core#19829 ]]: bitcoin/bitcoin@78040f9 Depends on D10866. Ref T1696. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Subscribers: PiRK Maniphest Tasks: T1696 Differential Revision: https://reviews.bitcoinabc.org/D10867
1 parent eab6942 commit a694ef7

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

src/net.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ struct CNodeStats {
789789
std::string cleanSubVer;
790790
bool fInbound;
791791
bool m_manual_connection;
792-
int nStartingHeight;
792+
int m_starting_height;
793793
uint64_t nSendBytes;
794794
mapMsgCmdSize mapSendBytesPerMsgCmd;
795795
uint64_t nRecvBytes;

src/net_processing.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ bool PeerManager::GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
12151215
if (peer == nullptr) {
12161216
return false;
12171217
}
1218-
stats.nStartingHeight = peer->nStartingHeight;
1218+
stats.m_starting_height = peer->m_starting_height;
12191219

12201220
return true;
12211221
}
@@ -2410,7 +2410,7 @@ void PeerManager::ProcessHeadersMessage(
24102410
LogPrint(
24112411
BCLog::NET,
24122412
"more getheaders (%d) to end to peer=%d (startheight:%d)\n",
2413-
pindexLast->nHeight, pfrom.GetId(), peer.nStartingHeight);
2413+
pindexLast->nHeight, pfrom.GetId(), peer.m_starting_height);
24142414
m_connman.PushMessage(
24152415
&pfrom, msgMaker.Make(NetMsgType::GETHEADERS,
24162416
::ChainActive().GetLocator(pindexLast),
@@ -2939,7 +2939,7 @@ void PeerManager::ProcessMessage(const Config &config, CNode &pfrom,
29392939
ServiceFlags nServices;
29402940
int nVersion;
29412941
std::string cleanSubVer;
2942-
int nStartingHeight = -1;
2942+
int starting_height = -1;
29432943
bool fRelay = true;
29442944
uint64_t nExtraEntropy = 1;
29452945

@@ -2977,7 +2977,7 @@ void PeerManager::ProcessMessage(const Config &config, CNode &pfrom,
29772977
cleanSubVer = SanitizeString(strSubVer);
29782978
}
29792979
if (!vRecv.empty()) {
2980-
vRecv >> nStartingHeight;
2980+
vRecv >> starting_height;
29812981
}
29822982
if (!vRecv.empty()) {
29832983
vRecv >> fRelay;
@@ -3021,7 +3021,7 @@ void PeerManager::ProcessMessage(const Config &config, CNode &pfrom,
30213021
LOCK(pfrom.cs_SubVer);
30223022
pfrom.cleanSubVer = cleanSubVer;
30233023
}
3024-
peer->nStartingHeight = nStartingHeight;
3024+
peer->m_starting_height = starting_height;
30253025

30263026
// set nodes not relaying blocks and tx and not serving (parts) of the
30273027
// historical blockchain as "clients"
@@ -3110,7 +3110,7 @@ void PeerManager::ProcessMessage(const Config &config, CNode &pfrom,
31103110
"receive version message: [%s] %s: version %d, blocks=%d, "
31113111
"us=%s, peer=%d%s\n",
31123112
pfrom.addr.ToString(), cleanSubVer, pfrom.nVersion,
3113-
peer->nStartingHeight, addrMe.ToString(), pfrom.GetId(),
3113+
peer->m_starting_height, addrMe.ToString(), pfrom.GetId(),
31143114
remoteAddr);
31153115

31163116
// Ignore time offsets that are improbable (before the Genesis block)
@@ -3150,7 +3150,7 @@ void PeerManager::ProcessMessage(const Config &config, CNode &pfrom,
31503150
LogPrintf(
31513151
"New outbound peer connected: version: %d, blocks=%d, "
31523152
"peer=%d%s (%s)\n",
3153-
pfrom.nVersion.load(), peer->nStartingHeight, pfrom.GetId(),
3153+
pfrom.nVersion.load(), peer->m_starting_height, pfrom.GetId(),
31543154
(fLogIPs ? strprintf(", peeraddr=%s", pfrom.addr.ToString())
31553155
: ""),
31563156
pfrom.m_tx_relay == nullptr ? "block-relay" : "full-relay");
@@ -5363,7 +5363,8 @@ bool PeerManager::SendMessages(const Config &config, CNode *pto,
53635363
LogPrint(
53645364
BCLog::NET,
53655365
"initial getheaders (%d) to peer=%d (startheight:%d)\n",
5366-
pindexStart->nHeight, pto->GetId(), peer->nStartingHeight);
5366+
pindexStart->nHeight, pto->GetId(),
5367+
peer->m_starting_height);
53675368
m_connman.PushMessage(
53685369
pto, msgMaker.Make(NetMsgType::GETHEADERS,
53695370
::ChainActive().GetLocator(pindexStart),

src/net_processing.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct CNodeStateStats {
4646
int m_misbehavior_score = 0;
4747
int nSyncHeight = -1;
4848
int nCommonHeight = -1;
49-
int nStartingHeight = -1;
49+
int m_starting_height = -1;
5050
std::vector<int> vHeightInFlight;
5151
};
5252

@@ -76,7 +76,7 @@ struct Peer {
7676
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
7777

7878
/** This peer's reported block height when we connected */
79-
std::atomic<int> nStartingHeight{-1};
79+
std::atomic<int> m_starting_height{-1};
8080

8181
/**
8282
* Set of txids to reconsider once their parent transactions have been

src/qt/rpcconsole.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ void RPCConsole::updateDetailWidget() {
13261326
}
13271327

13281328
ui->peerHeight->setText(
1329-
QString::number(stats->nodeStateStats.nStartingHeight));
1329+
QString::number(stats->nodeStateStats.m_starting_height));
13301330
}
13311331

13321332
ui->detailWidget->show();

src/rpc/net.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static RPCHelpMan getpeerinfo() {
273273
obj.pushKV("addnode", stats.m_manual_connection);
274274
}
275275
if (fStateStats) {
276-
obj.pushKV("startingheight", statestats.nStartingHeight);
276+
obj.pushKV("startingheight", statestats.m_starting_height);
277277
obj.pushKV("synced_headers", statestats.nSyncHeight);
278278
obj.pushKV("synced_blocks", statestats.nCommonHeight);
279279
UniValue heights(UniValue::VARR);

0 commit comments

Comments
 (0)