From 482126f3bcb30ec05f2831887061cca9d0b31369 Mon Sep 17 00:00:00 2001 From: Jim Posen Date: Fri, 28 Feb 2020 17:05:44 -0800 Subject: [PATCH] const all the things. Github-Pull: #16442 Rebased-From: 3007ee61fd922d79401e1bf9832df4ca6e7ab707 --- src/init.cpp | 6 +++--- src/net_processing.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index b2522ccffca55..fb1c3b9d3d8a3 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -968,9 +968,9 @@ bool AppInitParameterInteraction() // Signal NODE_COMPACT_FILTERS if peercfilters and required index are both enabled. if (gArgs.GetBoolArg("-peercfilters", DEFAULT_PEERCFILTERS)) { - bool index_enabled = std::find(g_enabled_filter_types.begin(), - g_enabled_filter_types.end(), - BlockFilterType::BASIC) != g_enabled_filter_types.end(); + const bool index_enabled = std::find(g_enabled_filter_types.begin(), + g_enabled_filter_types.end(), + BlockFilterType::BASIC) != g_enabled_filter_types.end(); if (!index_enabled) { return InitError(_("Cannot set -peercfilters without -blockfilterindex.").translated); } diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 022fbed2aaa58..e71872b7023ec 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1230,7 +1230,7 @@ static bool UpdateCFHeadersCache(const BlockFilterIndex& filter_index) for (uint32_t height = (new_size + 1) * CFCHECKPT_INTERVAL; height <= static_cast(active_chain.Height()); height += CFCHECKPT_INTERVAL) { - const CBlockIndex* block_index = active_chain[height]; + const CBlockIndex* const block_index = active_chain[height]; uint256 filter_header; if (!filter_index.LookupFilterHeader(block_index, filter_header)) { @@ -1923,7 +1923,7 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa const CBlockIndex*& stop_index, BlockFilterIndex*& filter_index) { - bool supported_filter_type = + const bool supported_filter_type = (filter_type == BlockFilterType::BASIC && (pfrom->GetLocalServices() & NODE_COMPACT_FILTERS)); if (!supported_filter_type) { @@ -1981,7 +1981,7 @@ static bool ProcessGetCFilters(CNode* pfrom, CDataStream& vRecv, const CChainPar vRecv >> filter_type_ser >> start_height >> stop_hash; - BlockFilterType filter_type = static_cast(filter_type_ser); + const BlockFilterType filter_type = static_cast(filter_type_ser); const CBlockIndex* stop_index; BlockFilterIndex* filter_index; @@ -2016,7 +2016,7 @@ static bool ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainPa vRecv >> filter_type_ser >> start_height >> stop_hash; - BlockFilterType filter_type = static_cast(filter_type_ser); + const BlockFilterType filter_type = static_cast(filter_type_ser); const CBlockIndex* stop_index; BlockFilterIndex* filter_index; @@ -2028,7 +2028,8 @@ static bool ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainPa uint256 prev_header; if (start_height > 0) { - const CBlockIndex* prev_block = stop_index->GetAncestor(start_height - 1); + const CBlockIndex* const prev_block = + stop_index->GetAncestor(static_cast(start_height - 1)); if (!filter_index->LookupFilterHeader(prev_block, prev_header)) { return error("Failed to find block filter header in index: filter_type=%s, block_hash=%s", BlockFilterTypeName(filter_type), prev_block->GetBlockHash().ToString()); @@ -2060,7 +2061,7 @@ static bool ProcessGetCFCheckPt(CNode* pfrom, CDataStream& vRecv, const CChainPa vRecv >> filter_type_ser >> stop_hash; - BlockFilterType filter_type = static_cast(filter_type_ser); + const BlockFilterType filter_type = static_cast(filter_type_ser); const CBlockIndex* stop_index; BlockFilterIndex* filter_index;