@@ -110,7 +110,8 @@ static int ComputeNextBlockAndDepth(const CBlockIndex* tip, const CBlockIndex* b
110110 return blockindex == tip ? 1 : -1 ;
111111}
112112
113- CBlockIndex* ParseHashOrHeight (const UniValue& param, ChainstateManager& chainman) {
113+ static const CBlockIndex* ParseHashOrHeight (const UniValue& param, ChainstateManager& chainman)
114+ {
114115 LOCK (::cs_main);
115116 CChain& active_chain = chainman.ActiveChain ();
116117
@@ -127,7 +128,7 @@ CBlockIndex* ParseHashOrHeight(const UniValue& param, ChainstateManager& chainma
127128 return active_chain[height];
128129 } else {
129130 const uint256 hash{ParseHashV (param, " hash_or_height" )};
130- CBlockIndex* pindex = chainman.m_blockman .LookupBlockIndex (hash);
131+ const CBlockIndex* pindex = chainman.m_blockman .LookupBlockIndex (hash);
131132
132133 if (!pindex) {
133134 throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found" );
@@ -854,7 +855,7 @@ static RPCHelpMan getblockhash()
854855 if (nHeight < 0 || nHeight > active_chain.Height ())
855856 throw JSONRPCError (RPC_INVALID_PARAMETER, " Block height out of range" );
856857
857- CBlockIndex* pblockindex = active_chain[nHeight];
858+ const CBlockIndex* pblockindex = active_chain[nHeight];
858859 return pblockindex->GetBlockHash ().GetHex ();
859860},
860861 };
@@ -1132,7 +1133,7 @@ static RPCHelpMan pruneblockchain()
11321133 // too low to be a block time (corresponds to timestamp from Sep 2001).
11331134 if (heightParam > 1000000000 ) {
11341135 // Add a 2 hour buffer to include blocks which might have had old timestamps
1135- CBlockIndex* pindex = active_chain.FindEarliestAtLeast (heightParam - TIMESTAMP_WINDOW, 0 );
1136+ const CBlockIndex* pindex = active_chain.FindEarliestAtLeast (heightParam - TIMESTAMP_WINDOW, 0 );
11361137 if (!pindex) {
11371138 throw JSONRPCError (RPC_INVALID_PARAMETER, " Could not find block with at least the specified timestamp." );
11381139 }
@@ -1226,7 +1227,7 @@ static RPCHelpMan gettxoutsetinfo()
12261227{
12271228 UniValue ret (UniValue::VOBJ);
12281229
1229- CBlockIndex* pindex{nullptr };
1230+ const CBlockIndex* pindex{nullptr };
12301231 const CoinStatsHashType hash_type{request.params [0 ].isNull () ? CoinStatsHashType::HASH_SERIALIZED : ParseHashType (request.params [0 ].get_str ())};
12311232 CCoinsStats stats{hash_type};
12321233 stats.index_requested = request.params [2 ].isNull () || request.params [2 ].get_bool ();
@@ -2177,7 +2178,7 @@ static RPCHelpMan getblockstats()
21772178{
21782179 ChainstateManager& chainman = EnsureAnyChainman (request.context );
21792180 LOCK (cs_main);
2180- CBlockIndex* pindex{ParseHashOrHeight (request.params [0 ], chainman)};
2181+ const CBlockIndex* pindex{ParseHashOrHeight (request.params [0 ], chainman)};
21812182 CHECK_NONFATAL (pindex != nullptr );
21822183
21832184 std::set<std::string> stats;
@@ -2572,7 +2573,7 @@ static RPCHelpMan scantxoutset()
25722573 g_should_abort_scan = false ;
25732574 int64_t count = 0 ;
25742575 std::unique_ptr<CCoinsViewCursor> pcursor;
2575- CBlockIndex* tip;
2576+ const CBlockIndex* tip;
25762577 NodeContext& node = EnsureAnyNodeContext (request.context );
25772578 {
25782579 ChainstateManager& chainman = EnsureChainman (node);
@@ -2760,7 +2761,7 @@ UniValue CreateUTXOSnapshot(
27602761{
27612762 std::unique_ptr<CCoinsViewCursor> pcursor;
27622763 CCoinsStats stats{CoinStatsHashType::HASH_SERIALIZED};
2763- CBlockIndex* tip;
2764+ const CBlockIndex* tip;
27642765
27652766 {
27662767 // We need to lock cs_main to ensure that the coinsdb isn't written to
0 commit comments