aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2021-01-08 18:56:48 -0500
committerCarl Dong <contact@carldong.me>2022-02-22 11:52:19 -0500
commitbec86ae32683ac56b4e6ba9c9b7d21cfbdf4ac03 (patch)
tree6a33e577b9c1aaa26b1cecfaf515ea15dd1351e5 /src/rpc
parentc44e734dca64a15fae92255a5d848c04adaad2fa (diff)
downloadbitcoin-bec86ae32683ac56b4e6ba9c9b7d21cfbdf4ac03.tar.xz
blockstorage: Make m_block_index own CBlockIndex's
Instead of having CBlockIndex's live on the heap, which requires manual memory management, have them be owned by m_block_index. This means that they will live and die with BlockManager. A change to BlockManager::LookupBlockIndex: - Previously, it was a const member function returning a non-const CBlockIndex* - Now, there's are const and non-const versions of BlockManager::LookupBlockIndex returning a CBlockIndex with the same const-ness as the member function: (e.g. const CBlockIndex* LookupBlockIndex(...) const) See next commit for some weirdness that this eliminates. The range based for-loops are modernize (using auto + destructuring) in a future commit.
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/blockchain.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 9817c80cbd..2c69fdd457 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1753,10 +1753,10 @@ static RPCHelpMan getchaintips()
std::set<const CBlockIndex*> setOrphans;
std::set<const CBlockIndex*> setPrevs;
- for (const std::pair<const uint256, CBlockIndex*>& item : chainman.BlockIndex()) {
- if (!active_chain.Contains(item.second)) {
- setOrphans.insert(item.second);
- setPrevs.insert(item.second->pprev);
+ for (const std::pair<const uint256, CBlockIndex>& item : chainman.BlockIndex()) {
+ if (!active_chain.Contains(&item.second)) {
+ setOrphans.insert(&item.second);
+ setPrevs.insert(item.second.pprev);
}
}