aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2022-03-02 15:42:57 +1000
committerCarl Dong <contact@carldong.me>2022-03-09 14:32:47 -0500
commit5be9ee3c54dcb396ff52fc8c8b7e4e6e39ec4a3b (patch)
tree8b28727e7425f6ffd9f7eb6d86c978befdbb1b23 /src/node
parent430acb7d2a3272977d5a66bf9a09bcd55ffd15cc (diff)
downloadbitcoin-5be9ee3c54dcb396ff52fc8c8b7e4e6e39ec4a3b.tar.xz
refactor: more const annotations for uses of CBlockIndex*
Diffstat (limited to 'src/node')
-rw-r--r--src/node/blockstorage.cpp4
-rw-r--r--src/node/blockstorage.h2
-rw-r--r--src/node/interfaces.cpp4
-rw-r--r--src/node/miner.cpp2
4 files changed, 6 insertions, 6 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 7392830261..c35d2a51ce 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -408,13 +408,13 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
return true;
}
-CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
+const CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
{
const MapCheckpoints& checkpoints = data.mapCheckpoints;
for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints)) {
const uint256& hash = i.second;
- CBlockIndex* pindex = LookupBlockIndex(hash);
+ const CBlockIndex* pindex = LookupBlockIndex(hash);
if (pindex) {
return pindex;
}
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index 12224f7a5d..69aed28cab 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -163,7 +163,7 @@ public:
uint64_t CalculateCurrentUsage();
//! Returns last CBlockIndex* that is a checkpoint
- CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+ const CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
~BlockManager()
{
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index cb063ae9f8..74d53d2062 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -490,7 +490,7 @@ public:
{
LOCK(cs_main);
const CChainState& active = Assert(m_node.chainman)->ActiveChainstate();
- if (CBlockIndex* fork = active.FindForkInGlobalIndex(locator)) {
+ if (const CBlockIndex* fork = active.FindForkInGlobalIndex(locator)) {
return fork->nHeight;
}
return std::nullopt;
@@ -557,7 +557,7 @@ public:
// used to limit the range, and passing min_height that's too low or
// max_height that's too high will not crash or change the result.
LOCK(::cs_main);
- if (CBlockIndex* block = chainman().m_blockman.LookupBlockIndex(block_hash)) {
+ if (const CBlockIndex* block = chainman().m_blockman.LookupBlockIndex(block_hash)) {
if (max_height && block->nHeight >= *max_height) block = block->GetAncestor(*max_height);
for (; block->nStatus & BLOCK_HAVE_DATA; block = block->pprev) {
// Check pprev to not segfault if min_height is too low
diff --git a/src/node/miner.cpp b/src/node/miner.cpp
index 7fe10ecabc..fbfa88c170 100644
--- a/src/node/miner.cpp
+++ b/src/node/miner.cpp
@@ -50,7 +50,7 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
tx.vout.erase(tx.vout.begin() + GetWitnessCommitmentIndex(block));
block.vtx.at(0) = MakeTransactionRef(tx);
- CBlockIndex* prev_block = WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(block.hashPrevBlock));
+ const CBlockIndex* prev_block = WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(block.hashPrevBlock));
GenerateCoinbaseCommitment(block, prev_block, Params().GetConsensus());
block.hashMerkleRoot = BlockMerkleRoot(block);