diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2242,7 +2242,7 @@ * * May disconnect from the peer in the case of a bad request. * - * @param[in] pfrom The peer that we received the request from + * @param[in] peer The peer that we received the request from * @param[in] chain_params Chain parameters * @param[in] filter_type The filter type the request is for. Must be * basic filters. @@ -2257,7 +2257,7 @@ * @return True if the request can be serviced. */ static bool PrepareBlockFilterRequest( - CNode &pfrom, const CChainParams &chain_params, BlockFilterType filter_type, + CNode &peer, const CChainParams &chain_params, BlockFilterType filter_type, uint32_t start_height, const BlockHash &stop_hash, uint32_t max_height_diff, const CBlockIndex *&stop_index, BlockFilterIndex *&filter_index) { const bool supported_filter_type = @@ -2266,8 +2266,8 @@ if (!supported_filter_type) { LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n", - pfrom.GetId(), static_cast(filter_type)); - pfrom.fDisconnect = true; + peer.GetId(), static_cast(filter_type)); + peer.fDisconnect = true; return false; } @@ -2280,8 +2280,8 @@ if (!stop_index || !BlockRequestAllowed(stop_index, chain_params.GetConsensus())) { LogPrint(BCLog::NET, "peer %d requested invalid block hash: %s\n", - pfrom.GetId(), stop_hash.ToString()); - pfrom.fDisconnect = true; + peer.GetId(), stop_hash.ToString()); + peer.fDisconnect = true; return false; } } @@ -2293,16 +2293,15 @@ "peer %d sent invalid getcfilters/getcfheaders with " /* Continued */ "start height %d and stop height %d\n", - pfrom.GetId(), start_height, stop_height); - pfrom.fDisconnect = true; + peer.GetId(), start_height, stop_height); + peer.fDisconnect = true; return false; } if (stop_height - start_height >= max_height_diff) { LogPrint(BCLog::NET, "peer %d requested too many cfilters/cfheaders: %d / %d\n", - pfrom.GetId(), stop_height - start_height + 1, - max_height_diff); - pfrom.fDisconnect = true; + peer.GetId(), stop_height - start_height + 1, max_height_diff); + peer.fDisconnect = true; return false; } @@ -2321,12 +2320,12 @@ * * May disconnect from the peer in the case of a bad request. * - * @param[in] pfrom The peer that we received the request from + * @param[in] peer The peer that we received the request from * @param[in] vRecv The raw message received * @param[in] chain_params Chain parameters * @param[in] connman Pointer to the connection manager */ -static void ProcessGetCFilters(CNode &pfrom, CDataStream &vRecv, +static void ProcessGetCFilters(CNode &peer, CDataStream &vRecv, const CChainParams &chain_params, CConnman &connman) { uint8_t filter_type_ser; @@ -2341,13 +2340,12 @@ const CBlockIndex *stop_index; BlockFilterIndex *filter_index; if (!PrepareBlockFilterRequest( - pfrom, chain_params, filter_type, start_height, stop_hash, + peer, chain_params, filter_type, start_height, stop_hash, MAX_GETCFILTERS_SIZE, stop_index, filter_index)) { return; } std::vector filters; - if (!filter_index->LookupFilterRange(start_height, stop_index, filters)) { LogPrint(BCLog::NET, "Failed to find block filter in index: filter_type=%s, " @@ -2358,9 +2356,9 @@ } for (const auto &filter : filters) { - CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion()) + CSerializedNetMsg msg = CNetMsgMaker(peer.GetSendVersion()) .Make(NetMsgType::CFILTER, filter); - connman.PushMessage(&pfrom, std::move(msg)); + connman.PushMessage(&peer, std::move(msg)); } } @@ -2369,12 +2367,12 @@ * * May disconnect from the peer in the case of a bad request. * - * @param[in] pfrom The peer that we received the request from + * @param[in] peer The peer that we received the request from * @param[in] vRecv The raw message received * @param[in] chain_params Chain parameters * @param[in] connman Pointer to the connection manager */ -static void ProcessGetCFHeaders(CNode &pfrom, CDataStream &vRecv, +static void ProcessGetCFHeaders(CNode &peer, CDataStream &vRecv, const CChainParams &chain_params, CConnman &connman) { uint8_t filter_type_ser; @@ -2389,7 +2387,7 @@ const CBlockIndex *stop_index; BlockFilterIndex *filter_index; if (!PrepareBlockFilterRequest( - pfrom, chain_params, filter_type, start_height, stop_hash, + peer, chain_params, filter_type, start_height, stop_hash, MAX_GETCFHEADERS_SIZE, stop_index, filter_index)) { return; } @@ -2420,10 +2418,10 @@ } CSerializedNetMsg msg = - CNetMsgMaker(pfrom.GetSendVersion()) + CNetMsgMaker(peer.GetSendVersion()) .Make(NetMsgType::CFHEADERS, filter_type_ser, stop_index->GetBlockHash(), prev_header, filter_hashes); - connman.PushMessage(&pfrom, std::move(msg)); + connman.PushMessage(&peer, std::move(msg)); } /** @@ -2431,12 +2429,12 @@ * * May disconnect from the peer in the case of a bad request. * - * @param[in] pfrom The peer that we received the request from + * @param[in] peer The peer that we received the request from * @param[in] vRecv The raw message received * @param[in] chain_params Chain parameters * @param[in] connman Pointer to the connection manager */ -static void ProcessGetCFCheckPt(CNode &pfrom, CDataStream &vRecv, +static void ProcessGetCFCheckPt(CNode &peer, CDataStream &vRecv, const CChainParams &chain_params, CConnman &connman) { uint8_t filter_type_ser; @@ -2450,7 +2448,7 @@ const CBlockIndex *stop_index; BlockFilterIndex *filter_index; if (!PrepareBlockFilterRequest( - pfrom, chain_params, filter_type, /*start_height=*/0, stop_hash, + peer, chain_params, filter_type, /*start_height=*/0, stop_hash, /*max_height_diff=*/std::numeric_limits::max(), stop_index, filter_index)) { return; @@ -2474,10 +2472,10 @@ } } - CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion()) + CSerializedNetMsg msg = CNetMsgMaker(peer.GetSendVersion()) .Make(NetMsgType::CFCHECKPT, filter_type_ser, stop_index->GetBlockHash(), headers); - connman.PushMessage(&pfrom, std::move(msg)); + connman.PushMessage(&peer, std::move(msg)); } bool ProcessMessage(const Config &config, CNode &pfrom, diff --git a/test/functional/p2p_blockfilters.py b/test/functional/p2p_blockfilters.py --- a/test/functional/p2p_blockfilters.py +++ b/test/functional/p2p_blockfilters.py @@ -5,7 +5,7 @@ """Tests NODE_COMPACT_FILTERS (BIP 157/158). Tests that a node configured with -blockfilterindex and -peerblockfilters can serve -cfheaders and cfcheckpts. +cfilters, cfheaders and cfcheckpts. """ from test_framework.messages import (