Skip to content

Commit bb911ae

Browse files
committed
[refactor] Pass CNode and CConnman by reference
Pass CNode and CConnman by reference instead of by pointer to ProcessGetCFCheckPt() and ProcessGetCFHeaders().
1 parent dcacea0 commit bb911ae

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/net_processing.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ void static ProcessOrphanTx(CConnman* connman, CTxMemPool& mempool, std::set<uin
19981998
* @param[out] filter_index The filter index, if the request can be serviced.
19991999
* @return True if the request can be serviced.
20002000
*/
2001-
static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_params,
2001+
static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_params,
20022002
BlockFilterType filter_type, uint32_t start_height,
20032003
const uint256& stop_hash, uint32_t max_height_diff,
20042004
const CBlockIndex*& stop_index,
@@ -2009,8 +2009,8 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
20092009
gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS));
20102010
if (!supported_filter_type) {
20112011
LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n",
2012-
pfrom->GetId(), static_cast<uint8_t>(filter_type));
2013-
pfrom->fDisconnect = true;
2012+
pfrom.GetId(), static_cast<uint8_t>(filter_type));
2013+
pfrom.fDisconnect = true;
20142014
return false;
20152015
}
20162016

@@ -2021,8 +2021,8 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
20212021
// Check that the stop block exists and the peer would be allowed to fetch it.
20222022
if (!stop_index || !BlockRequestAllowed(stop_index, chain_params.GetConsensus())) {
20232023
LogPrint(BCLog::NET, "peer %d requested invalid block hash: %s\n",
2024-
pfrom->GetId(), stop_hash.ToString());
2025-
pfrom->fDisconnect = true;
2024+
pfrom.GetId(), stop_hash.ToString());
2025+
pfrom.fDisconnect = true;
20262026
return false;
20272027
}
20282028
}
@@ -2031,14 +2031,14 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
20312031
if (start_height > stop_height) {
20322032
LogPrint(BCLog::NET, "peer %d sent invalid getcfilters/getcfheaders with " /* Continued */
20332033
"start height %d and stop height %d\n",
2034-
pfrom->GetId(), start_height, stop_height);
2035-
pfrom->fDisconnect = true;
2034+
pfrom.GetId(), start_height, stop_height);
2035+
pfrom.fDisconnect = true;
20362036
return false;
20372037
}
20382038
if (stop_height - start_height >= max_height_diff) {
20392039
LogPrint(BCLog::NET, "peer %d requested too many cfilters/cfheaders: %d / %d\n",
2040-
pfrom->GetId(), stop_height - start_height + 1, max_height_diff);
2041-
pfrom->fDisconnect = true;
2040+
pfrom.GetId(), stop_height - start_height + 1, max_height_diff);
2041+
pfrom.fDisconnect = true;
20422042
return false;
20432043
}
20442044

@@ -2061,8 +2061,8 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
20612061
* @param[in] chain_params Chain parameters
20622062
* @param[in] connman Pointer to the connection manager
20632063
*/
2064-
static void ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainParams& chain_params,
2065-
CConnman* connman)
2064+
static void ProcessGetCFHeaders(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
2065+
CConnman& connman)
20662066
{
20672067
uint8_t filter_type_ser;
20682068
uint32_t start_height;
@@ -2097,13 +2097,13 @@ static void ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainPa
20972097
return;
20982098
}
20992099

2100-
CSerializedNetMsg msg = CNetMsgMaker(pfrom->GetSendVersion())
2100+
CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
21012101
.Make(NetMsgType::CFHEADERS,
21022102
filter_type_ser,
21032103
stop_index->GetBlockHash(),
21042104
prev_header,
21052105
filter_hashes);
2106-
connman->PushMessage(pfrom, std::move(msg));
2106+
connman.PushMessage(&pfrom, std::move(msg));
21072107
}
21082108

21092109
/**
@@ -2116,8 +2116,8 @@ static void ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainPa
21162116
* @param[in] chain_params Chain parameters
21172117
* @param[in] connman Pointer to the connection manager
21182118
*/
2119-
static void ProcessGetCFCheckPt(CNode* pfrom, CDataStream& vRecv, const CChainParams& chain_params,
2120-
CConnman* connman)
2119+
static void ProcessGetCFCheckPt(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
2120+
CConnman& connman)
21212121
{
21222122
uint8_t filter_type_ser;
21232123
uint256 stop_hash;
@@ -2149,12 +2149,12 @@ static void ProcessGetCFCheckPt(CNode* pfrom, CDataStream& vRecv, const CChainPa
21492149
}
21502150
}
21512151

2152-
CSerializedNetMsg msg = CNetMsgMaker(pfrom->GetSendVersion())
2152+
CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
21532153
.Make(NetMsgType::CFCHECKPT,
21542154
filter_type_ser,
21552155
stop_index->GetBlockHash(),
21562156
headers);
2157-
connman->PushMessage(pfrom, std::move(msg));
2157+
connman.PushMessage(&pfrom, std::move(msg));
21582158
}
21592159

21602160
bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, ChainstateManager& chainman, CTxMemPool& mempool, CConnman* connman, BanMan* banman, const std::atomic<bool>& interruptMsgProc)
@@ -3467,12 +3467,12 @@ bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRec
34673467
}
34683468

34693469
if (msg_type == NetMsgType::GETCFHEADERS) {
3470-
ProcessGetCFHeaders(pfrom, vRecv, chainparams, connman);
3470+
ProcessGetCFHeaders(*pfrom, vRecv, chainparams, *connman);
34713471
return true;
34723472
}
34733473

34743474
if (msg_type == NetMsgType::GETCFCHECKPT) {
3475-
ProcessGetCFCheckPt(pfrom, vRecv, chainparams, connman);
3475+
ProcessGetCFCheckPt(*pfrom, vRecv, chainparams, *connman);
34763476
return true;
34773477
}
34783478

0 commit comments

Comments
 (0)