Skip to content

Commit b3fbc94

Browse files
committed
Apply cfilters review fixups
1 parent a65b55f commit b3fbc94

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

src/net_processing.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ void static ProcessOrphanTx(CConnman* connman, CTxMemPool& mempool, std::set<uin
19911991
*
19921992
* May disconnect from the peer in the case of a bad request.
19931993
*
1994-
* @param[in] pfrom The peer that we received the request from
1994+
* @param[in] peer The peer that we received the request from
19951995
* @param[in] chain_params Chain parameters
19961996
* @param[in] filter_type The filter type the request is for. Must be basic filters.
19971997
* @param[in] start_height The start height for the request
@@ -2001,7 +2001,7 @@ void static ProcessOrphanTx(CConnman* connman, CTxMemPool& mempool, std::set<uin
20012001
* @param[out] filter_index The filter index, if the request can be serviced.
20022002
* @return True if the request can be serviced.
20032003
*/
2004-
static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_params,
2004+
static bool PrepareBlockFilterRequest(CNode& peer, const CChainParams& chain_params,
20052005
BlockFilterType filter_type, uint32_t start_height,
20062006
const uint256& stop_hash, uint32_t max_height_diff,
20072007
const CBlockIndex*& stop_index,
@@ -2012,8 +2012,8 @@ static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_pa
20122012
gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS));
20132013
if (!supported_filter_type) {
20142014
LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n",
2015-
pfrom.GetId(), static_cast<uint8_t>(filter_type));
2016-
pfrom.fDisconnect = true;
2015+
peer.GetId(), static_cast<uint8_t>(filter_type));
2016+
peer.fDisconnect = true;
20172017
return false;
20182018
}
20192019

@@ -2024,8 +2024,8 @@ static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_pa
20242024
// Check that the stop block exists and the peer would be allowed to fetch it.
20252025
if (!stop_index || !BlockRequestAllowed(stop_index, chain_params.GetConsensus())) {
20262026
LogPrint(BCLog::NET, "peer %d requested invalid block hash: %s\n",
2027-
pfrom.GetId(), stop_hash.ToString());
2028-
pfrom.fDisconnect = true;
2027+
peer.GetId(), stop_hash.ToString());
2028+
peer.fDisconnect = true;
20292029
return false;
20302030
}
20312031
}
@@ -2034,14 +2034,14 @@ static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_pa
20342034
if (start_height > stop_height) {
20352035
LogPrint(BCLog::NET, "peer %d sent invalid getcfilters/getcfheaders with " /* Continued */
20362036
"start height %d and stop height %d\n",
2037-
pfrom.GetId(), start_height, stop_height);
2038-
pfrom.fDisconnect = true;
2037+
peer.GetId(), start_height, stop_height);
2038+
peer.fDisconnect = true;
20392039
return false;
20402040
}
20412041
if (stop_height - start_height >= max_height_diff) {
20422042
LogPrint(BCLog::NET, "peer %d requested too many cfilters/cfheaders: %d / %d\n",
2043-
pfrom.GetId(), stop_height - start_height + 1, max_height_diff);
2044-
pfrom.fDisconnect = true;
2043+
peer.GetId(), stop_height - start_height + 1, max_height_diff);
2044+
peer.fDisconnect = true;
20452045
return false;
20462046
}
20472047

@@ -2059,12 +2059,12 @@ static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_pa
20592059
*
20602060
* May disconnect from the peer in the case of a bad request.
20612061
*
2062-
* @param[in] pfrom The peer that we received the request from
2062+
* @param[in] peer The peer that we received the request from
20632063
* @param[in] vRecv The raw message received
20642064
* @param[in] chain_params Chain parameters
20652065
* @param[in] connman Pointer to the connection manager
20662066
*/
2067-
static void ProcessGetCFilters(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
2067+
static void ProcessGetCFilters(CNode& peer, CDataStream& vRecv, const CChainParams& chain_params,
20682068
CConnman& connman)
20692069
{
20702070
uint8_t filter_type_ser;
@@ -2077,23 +2077,22 @@ static void ProcessGetCFilters(CNode& pfrom, CDataStream& vRecv, const CChainPar
20772077

20782078
const CBlockIndex* stop_index;
20792079
BlockFilterIndex* filter_index;
2080-
if (!PrepareBlockFilterRequest(pfrom, chain_params, filter_type, start_height, stop_hash,
2080+
if (!PrepareBlockFilterRequest(peer, chain_params, filter_type, start_height, stop_hash,
20812081
MAX_GETCFILTERS_SIZE, stop_index, filter_index)) {
20822082
return;
20832083
}
20842084

20852085
std::vector<BlockFilter> filters;
2086-
20872086
if (!filter_index->LookupFilterRange(start_height, stop_index, filters)) {
20882087
LogPrint(BCLog::NET, "Failed to find block filter in index: filter_type=%s, start_height=%d, stop_hash=%s\n",
20892088
BlockFilterTypeName(filter_type), start_height, stop_hash.ToString());
20902089
return;
20912090
}
20922091

20932092
for (const auto& filter : filters) {
2094-
CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
2093+
CSerializedNetMsg msg = CNetMsgMaker(peer.GetSendVersion())
20952094
.Make(NetMsgType::CFILTER, filter);
2096-
connman.PushMessage(&pfrom, std::move(msg));
2095+
connman.PushMessage(&peer, std::move(msg));
20972096
}
20982097
}
20992098

@@ -2102,12 +2101,12 @@ static void ProcessGetCFilters(CNode& pfrom, CDataStream& vRecv, const CChainPar
21022101
*
21032102
* May disconnect from the peer in the case of a bad request.
21042103
*
2105-
* @param[in] pfrom The peer that we received the request from
2104+
* @param[in] peer The peer that we received the request from
21062105
* @param[in] vRecv The raw message received
21072106
* @param[in] chain_params Chain parameters
21082107
* @param[in] connman Pointer to the connection manager
21092108
*/
2110-
static void ProcessGetCFHeaders(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
2109+
static void ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv, const CChainParams& chain_params,
21112110
CConnman& connman)
21122111
{
21132112
uint8_t filter_type_ser;
@@ -2120,7 +2119,7 @@ static void ProcessGetCFHeaders(CNode& pfrom, CDataStream& vRecv, const CChainPa
21202119

21212120
const CBlockIndex* stop_index;
21222121
BlockFilterIndex* filter_index;
2123-
if (!PrepareBlockFilterRequest(pfrom, chain_params, filter_type, start_height, stop_hash,
2122+
if (!PrepareBlockFilterRequest(peer, chain_params, filter_type, start_height, stop_hash,
21242123
MAX_GETCFHEADERS_SIZE, stop_index, filter_index)) {
21252124
return;
21262125
}
@@ -2143,26 +2142,26 @@ static void ProcessGetCFHeaders(CNode& pfrom, CDataStream& vRecv, const CChainPa
21432142
return;
21442143
}
21452144

2146-
CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
2145+
CSerializedNetMsg msg = CNetMsgMaker(peer.GetSendVersion())
21472146
.Make(NetMsgType::CFHEADERS,
21482147
filter_type_ser,
21492148
stop_index->GetBlockHash(),
21502149
prev_header,
21512150
filter_hashes);
2152-
connman.PushMessage(&pfrom, std::move(msg));
2151+
connman.PushMessage(&peer, std::move(msg));
21532152
}
21542153

21552154
/**
21562155
* Handle a getcfcheckpt request.
21572156
*
21582157
* May disconnect from the peer in the case of a bad request.
21592158
*
2160-
* @param[in] pfrom The peer that we received the request from
2159+
* @param[in] peer The peer that we received the request from
21612160
* @param[in] vRecv The raw message received
21622161
* @param[in] chain_params Chain parameters
21632162
* @param[in] connman Pointer to the connection manager
21642163
*/
2165-
static void ProcessGetCFCheckPt(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
2164+
static void ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv, const CChainParams& chain_params,
21662165
CConnman& connman)
21672166
{
21682167
uint8_t filter_type_ser;
@@ -2174,7 +2173,7 @@ static void ProcessGetCFCheckPt(CNode& pfrom, CDataStream& vRecv, const CChainPa
21742173

21752174
const CBlockIndex* stop_index;
21762175
BlockFilterIndex* filter_index;
2177-
if (!PrepareBlockFilterRequest(pfrom, chain_params, filter_type, /*start_height=*/0, stop_hash,
2176+
if (!PrepareBlockFilterRequest(peer, chain_params, filter_type, /*start_height=*/0, stop_hash,
21782177
/*max_height_diff=*/std::numeric_limits<uint32_t>::max(),
21792178
stop_index, filter_index)) {
21802179
return;
@@ -2195,12 +2194,12 @@ static void ProcessGetCFCheckPt(CNode& pfrom, CDataStream& vRecv, const CChainPa
21952194
}
21962195
}
21972196

2198-
CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
2197+
CSerializedNetMsg msg = CNetMsgMaker(peer.GetSendVersion())
21992198
.Make(NetMsgType::CFCHECKPT,
22002199
filter_type_ser,
22012200
stop_index->GetBlockHash(),
22022201
headers);
2203-
connman.PushMessage(&pfrom, std::move(msg));
2202+
connman.PushMessage(&peer, std::move(msg));
22042203
}
22052204

22062205
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)

test/functional/p2p_blockfilters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""Tests NODE_COMPACT_FILTERS (BIP 157/158).
66
77
Tests that a node configured with -blockfilterindex and -peerblockfilters can serve
8-
cfheaders and cfcheckpts.
8+
cfilters, cfheaders and cfcheckpts.
99
"""
1010

1111
from test_framework.messages import (

0 commit comments

Comments
 (0)