mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge #16194: refactor: share blockmetadata with BlockManager
682a1d0f20refactoring: remove mapBlockIndex global (James O'Beirne)55d525ab90refactoring: make pindexBestInvalid internal to validation.cpp (James O'Beirne)4ed55dfcd7refactoring: add block_index_candidates arg to LoadBlockIndex (James O'Beirne)613c46fe9erefactoring: move block metadata structures into BlockManager (James O'Beirne) Pull request description: This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11): Parent PR: #15606 Issue: #15605 Specification: https://github.com/jamesob/assumeutxo-docs/tree/2019-04-proposal/proposal --- Under an assumeutxo model, we have multiple CChainState instances in use at once in order to support background validation. Currently, each CChainState instance has its own mapBlockIndex, a collection of linked block headers, in addition to a few other data structures that are related to maintenance of the block tree but not necessarily to any given chainstate. In order to avoid duplicating this data across chainstates, this change moves chainstate-agnostic block metadata (and related behavior) into a class, `BlockManager`. Chainstates are parameterized with a reference to a blockmanager instance and in practice they share the same instance. Most of this change is conceptually move-only, though the diff is somewhat muddled. The first commit can be reviewed slightly more easily with `--color-moved=dimmed_zebra`. Admittedly, that commit is pretty unwieldy; I tried to split it up after the fact with `git add --patch`, but that was difficult because of git's inability to split hunks past a certain point. Some of the moves also ended up being obscured when done over separate commits. ACKs for top commit: MarcoFalke: ACK682a1d0f20ryanofsky: utACK682a1d0f20, only changes since last review were rebase and fixing conflict on a moved line ariard: utACK682a1d0. Most of the changes are move-only, with main problem being to avoid creating circular dependencies between `BlockManager` and `CChainState`. Tested, comments are mostly nits, feel free to ignore them Tree-SHA512: 738d8d06539ba53acf4bd2d48ae000473e645bbc4e63d798d55d247a4d5a4f781b73538ed590f6407be9ab402ea9d395570ea20bff0a4b9ce747bcc1600c5108
This commit is contained in:
@@ -1411,7 +1411,7 @@ static UniValue getchaintips(const JSONRPCRequest& request)
|
||||
/*
|
||||
* Idea: the set of chain tips is ::ChainActive().tip, plus orphan blocks which do not have another orphan building off of them.
|
||||
* Algorithm:
|
||||
* - Make one pass through mapBlockIndex, picking out the orphan blocks, and also storing a set of the orphan block's pprev pointers.
|
||||
* - Make one pass through g_blockman.m_block_index, picking out the orphan blocks, and also storing a set of the orphan block's pprev pointers.
|
||||
* - Iterate through the orphan blocks. If the block isn't pointed to by another orphan, it is a chain tip.
|
||||
* - add ::ChainActive().Tip()
|
||||
*/
|
||||
@@ -1419,7 +1419,7 @@ static UniValue getchaintips(const JSONRPCRequest& request)
|
||||
std::set<const CBlockIndex*> setOrphans;
|
||||
std::set<const CBlockIndex*> setPrevs;
|
||||
|
||||
for (const std::pair<const uint256, CBlockIndex*>& item : mapBlockIndex)
|
||||
for (const std::pair<const uint256, CBlockIndex*>& item : ::BlockIndex())
|
||||
{
|
||||
if (!::ChainActive().Contains(item.second)) {
|
||||
setOrphans.insert(item.second);
|
||||
|
||||
Reference in New Issue
Block a user