Skip to content

Commit

Permalink
scripted-diff: rename CChainState -> Chainstate
Browse files Browse the repository at this point in the history
-BEGIN VERIFY SCRIPT-
sed -i 's/CChainState/Chainstate/g' $(git grep -l CChainState ':(exclude)doc/release-notes*')
-END VERIFY SCRIPT-

Co-authored-by: MacroFake <falke.marco@gmail.com>
  • Loading branch information
jamesob and MacroFake committed Sep 9, 2022
1 parent 37095c7 commit 00eeb31
Show file tree
Hide file tree
Showing 33 changed files with 154 additions and 154 deletions.
4 changes: 2 additions & 2 deletions doc/design/assumeutxo.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ be of use.

Chainstate within the system goes through a number of phases when UTXO snapshots are
used, as managed by `ChainstateManager`. At various points there can be multiple
`CChainState` objects in existence to facilitate both maintaining the network tip and
`Chainstate` objects in existence to facilitate both maintaining the network tip and
performing historical validation of the assumed-valid chain.

It is worth noting that though there are multiple separate chainstates, those
Expand All @@ -53,7 +53,7 @@ data.

### "Normal" operation via initial block download

`ChainstateManager` manages a single CChainState object, for which
`ChainstateManager` manages a single Chainstate object, for which
`m_snapshot_blockhash` is null. This chainstate is (maybe obviously)
considered active. This is the "traditional" mode of operation for bitcoind.

Expand Down
4 changes: 2 additions & 2 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ void CTxMemPool::UpdateTransactionsFromBlock(...)

```C++
// validation.h
class CChainState
class Chainstate
{
protected:
...
Expand All @@ -983,7 +983,7 @@ public:
}

// validation.cpp
bool CChainState::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
bool Chainstate::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
{
AssertLockNotHeld(m_chainstate_mutex);
AssertLockNotHeld(::cs_main);
Expand Down
4 changes: 2 additions & 2 deletions src/bitcoin-chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int main(int argc, char* argv[])
}
}

for (CChainState* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
for (Chainstate* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
BlockValidationState state;
if (!chainstate->ActivateBestChain(state, nullptr)) {
std::cerr << "Failed to connect best block (" << state.ToString() << ")" << std::endl;
Expand Down Expand Up @@ -253,7 +253,7 @@ int main(int argc, char* argv[])
GetMainSignals().FlushBackgroundCallbacks();
{
LOCK(cs_main);
for (CChainState* chainstate : chainman.GetAll()) {
for (Chainstate* chainstate : chainman.GetAll()) {
if (chainstate->CanFlushToDisk()) {
chainstate->ForceFlushStateToDisk();
chainstate->ResetCoinsViews();
Expand Down
4 changes: 2 additions & 2 deletions src/index/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class CBlock;
class CBlockIndex;
class CChainState;
class Chainstate;
namespace interfaces {
class Chain;
} // namespace interfaces
Expand Down Expand Up @@ -94,7 +94,7 @@ class BaseIndex : public CValidationInterface

protected:
std::unique_ptr<interfaces::Chain> m_chain;
CChainState* m_chainstate{nullptr};
Chainstate* m_chainstate{nullptr};

void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override;

Expand Down
6 changes: 3 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void Shutdown(NodeContext& node)
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
if (node.chainman) {
LOCK(cs_main);
for (CChainState* chainstate : node.chainman->GetAll()) {
for (Chainstate* chainstate : node.chainman->GetAll()) {
if (chainstate->CanFlushToDisk()) {
chainstate->ForceFlushStateToDisk();
}
Expand Down Expand Up @@ -294,7 +294,7 @@ void Shutdown(NodeContext& node)

if (node.chainman) {
LOCK(cs_main);
for (CChainState* chainstate : node.chainman->GetAll()) {
for (Chainstate* chainstate : node.chainman->GetAll()) {
if (chainstate->CanFlushToDisk()) {
chainstate->ForceFlushStateToDisk();
chainstate->ResetCoinsViews();
Expand Down Expand Up @@ -1532,7 +1532,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (fPruneMode) {
if (!fReindex) {
LOCK(cs_main);
for (CChainState* chainstate : chainman.GetAll()) {
for (Chainstate* chainstate : chainman.GetAll()) {
uiInterface.InitMessage(_("Pruning blockstore…").translated);
chainstate->PruneAndFlush();
}
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/mempool_persist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace kernel {

static const uint64_t MEMPOOL_DUMP_VERSION = 1;

bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, CChainState& active_chainstate, FopenFn mockable_fopen_function)
bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active_chainstate, FopenFn mockable_fopen_function)
{
if (load_path.empty()) return false;

Expand Down
4 changes: 2 additions & 2 deletions src/kernel/mempool_persist.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <fs.h>

class CChainState;
class Chainstate;
class CTxMemPool;

namespace kernel {
Expand All @@ -19,7 +19,7 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path,

/** Load the mempool from disk. */
bool LoadMempool(CTxMemPool& pool, const fs::path& load_path,
CChainState& active_chainstate,
Chainstate& active_chainstate,
fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen);

} // namespace kernel
Expand Down
2 changes: 1 addition & 1 deletion src/node/blockstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
// We can't hold cs_main during ActivateBestChain even though we're accessing
// the chainman unique_ptrs since ABC requires us not to be holding cs_main, so retrieve
// the relevant pointers before the ABC call.
for (CChainState* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
for (Chainstate* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
BlockValidationState state;
if (!chainstate->ActivateBestChain(state, nullptr)) {
LogPrintf("Failed to connect best block (%s)\n", state.ToString());
Expand Down
6 changes: 3 additions & 3 deletions src/node/blockstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CBlockFileInfo;
class CBlockUndo;
class CChain;
class CChainParams;
class CChainState;
class Chainstate;
class ChainstateManager;
struct CCheckpointData;
struct FlatFilePos;
Expand Down Expand Up @@ -75,12 +75,12 @@ struct PruneLockInfo {
* Maintains a tree of blocks (stored in `m_block_index`) which is consulted
* to determine where the most-work tip is.
*
* This data is used mostly in `CChainState` - information about, e.g.,
* This data is used mostly in `Chainstate` - information about, e.g.,
* candidate tips is not maintained here.
*/
class BlockManager
{
friend CChainState;
friend Chainstate;
friend ChainstateManager;

private:
Expand Down
10 changes: 5 additions & 5 deletions src/node/chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace node {
ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes,
const ChainstateLoadOptions& options)
{
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
auto is_coinsview_empty = [&](Chainstate* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
return options.reindex || options.reindex_chainstate || chainstate->CoinsTip().GetBestBlock().IsNull();
};

Expand Down Expand Up @@ -101,7 +101,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
// At this point we're either in reindex or we've loaded a useful
// block tree into BlockIndex()!

for (CChainState* chainstate : chainman.GetAll()) {
for (Chainstate* chainstate : chainman.GetAll()) {
chainstate->InitCoinsDB(
/*cache_size_bytes=*/cache_sizes.coins_db,
/*in_memory=*/options.coins_db_in_memory,
Expand Down Expand Up @@ -140,7 +140,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
if (!options.reindex) {
auto chainstates{chainman.GetAll()};
if (std::any_of(chainstates.begin(), chainstates.end(),
[](const CChainState* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
[](const Chainstate* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
return {ChainstateLoadStatus::FAILURE, strprintf(_("Witness data for blocks after height %d requires validation. Please restart with -reindex."),
chainman.GetConsensus().SegwitHeight)};
};
Expand All @@ -151,13 +151,13 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize

ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager& chainman, const ChainstateLoadOptions& options)
{
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
auto is_coinsview_empty = [&](Chainstate* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
return options.reindex || options.reindex_chainstate || chainstate->CoinsTip().GetBestBlock().IsNull();
};

LOCK(cs_main);

for (CChainState* chainstate : chainman.GetAll()) {
for (Chainstate* chainstate : chainman.GetAll()) {
if (!is_coinsview_empty(chainstate)) {
const CBlockIndex* tip = chainstate->m_chain.Tip();
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {
Expand Down
4 changes: 2 additions & 2 deletions src/node/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BlockAssembler::Options::Options()
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
}

BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options)
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
: chainparams{chainstate.m_chainman.GetParams()},
m_mempool(mempool),
m_chainstate(chainstate)
Expand All @@ -87,7 +87,7 @@ static BlockAssembler::Options DefaultOptions()
return options;
}

BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool)
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool)
: BlockAssembler(chainstate, mempool, DefaultOptions()) {}

void BlockAssembler::resetBlock()
Expand Down
6 changes: 3 additions & 3 deletions src/node/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class BlockAssembler

const CChainParams& chainparams;
const CTxMemPool* const m_mempool;
CChainState& m_chainstate;
Chainstate& m_chainstate;

public:
struct Options {
Expand All @@ -157,8 +157,8 @@ class BlockAssembler
CFeeRate blockMinFeeRate;
};

explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool);
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options);
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool);
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options);

/** Construct a new block template with coinbase to scriptPubKeyIn */
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
Expand Down
2 changes: 1 addition & 1 deletion src/node/utxo_snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace node {
//! Metadata describing a serialized version of a UTXO set from which an
//! assumeutxo CChainState can be constructed.
//! assumeutxo Chainstate can be constructed.
class SnapshotMetadata
{
public:
Expand Down
16 changes: 8 additions & 8 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ static RPCHelpMan pruneblockchain()

ChainstateManager& chainman = EnsureAnyChainman(request.context);
LOCK(cs_main);
CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();
CChain& active_chain = active_chainstate.m_chain;

int heightParam = request.params[0].getInt<int>();
Expand Down Expand Up @@ -908,7 +908,7 @@ static RPCHelpMan gettxoutsetinfo()

NodeContext& node = EnsureAnyNodeContext(request.context);
ChainstateManager& chainman = EnsureChainman(node);
CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();
active_chainstate.ForceFlushStateToDisk();

CCoinsView* coins_view;
Expand Down Expand Up @@ -1048,7 +1048,7 @@ static RPCHelpMan gettxout()
fMempool = request.params[2].get_bool();

Coin coin;
CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();
CCoinsViewCache* coins_view = &active_chainstate.CoinsTip();

if (fMempool) {
Expand Down Expand Up @@ -1105,7 +1105,7 @@ static RPCHelpMan verifychain()
ChainstateManager& chainman = EnsureAnyChainman(request.context);
LOCK(cs_main);

CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();
return CVerifyDB().VerifyDB(
active_chainstate, chainman.GetParams().GetConsensus(), active_chainstate.CoinsTip(), check_level, check_depth);
},
Expand Down Expand Up @@ -1233,7 +1233,7 @@ RPCHelpMan getblockchaininfo()
const ArgsManager& args{EnsureAnyArgsman(request.context)};
ChainstateManager& chainman = EnsureAnyChainman(request.context);
LOCK(cs_main);
CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();

const CBlockIndex& tip{*CHECK_NONFATAL(active_chainstate.m_chain.Tip())};
const int height{tip.nHeight};
Expand Down Expand Up @@ -1328,7 +1328,7 @@ static RPCHelpMan getdeploymentinfo()
{
const ChainstateManager& chainman = EnsureAnyChainman(request.context);
LOCK(cs_main);
const CChainState& active_chainstate = chainman.ActiveChainstate();
const Chainstate& active_chainstate = chainman.ActiveChainstate();

const CBlockIndex* blockindex;
if (request.params[0].isNull()) {
Expand Down Expand Up @@ -2148,7 +2148,7 @@ static RPCHelpMan scantxoutset()
{
ChainstateManager& chainman = EnsureChainman(node);
LOCK(cs_main);
CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();
active_chainstate.ForceFlushStateToDisk();
pcursor = CHECK_NONFATAL(active_chainstate.CoinsDB().Cursor());
tip = CHECK_NONFATAL(active_chainstate.m_chain.Tip());
Expand Down Expand Up @@ -2328,7 +2328,7 @@ static RPCHelpMan dumptxoutset()

UniValue CreateUTXOSnapshot(
NodeContext& node,
CChainState& chainstate,
Chainstate& chainstate,
AutoFile& afile,
const fs::path& path,
const fs::path& temppath)
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern RecursiveMutex cs_main;

class CBlock;
class CBlockIndex;
class CChainState;
class Chainstate;
class UniValue;
namespace node {
struct NodeContext;
Expand Down Expand Up @@ -54,7 +54,7 @@ void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES],
*/
UniValue CreateUTXOSnapshot(
node::NodeContext& node,
CChainState& chainstate,
Chainstate& chainstate,
AutoFile& afile,
const fs::path& path,
const fs::path& tmppath);
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static RPCHelpMan testmempoolaccept()
NodeContext& node = EnsureAnyNodeContext(request.context);
CTxMemPool& mempool = EnsureMemPool(node);
ChainstateManager& chainman = EnsureChainman(node);
CChainState& chainstate = chainman.ActiveChainstate();
Chainstate& chainstate = chainman.ActiveChainstate();
const PackageMempoolAcceptResult package_result = [&] {
LOCK(::cs_main);
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true);
Expand Down Expand Up @@ -810,7 +810,7 @@ static RPCHelpMan submitpackage()

NodeContext& node = EnsureAnyNodeContext(request.context);
CTxMemPool& mempool = EnsureMemPool(node);
CChainState& chainstate = EnsureChainman(node).ActiveChainstate();
Chainstate& chainstate = EnsureChainman(node).ActiveChainstate();
const auto package_result = WITH_LOCK(::cs_main, return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/ false));

// First catch any errors.
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static RPCHelpMan getblocktemplate()
std::string strMode = "template";
UniValue lpval = NullUniValue;
std::set<std::string> setClientRules;
CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();
CChain& active_chain = active_chainstate.m_chain;
if (!request.params[0].isNull())
{
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using node::GetTransaction;
using node::NodeContext;
using node::PSBTAnalysis;

static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, CChainState& active_chainstate)
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, Chainstate& active_chainstate)
{
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
//
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/txoutproof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static RPCHelpMan gettxoutproof()
}
} else {
LOCK(cs_main);
CChainState& active_chainstate = chainman.ActiveChainstate();
Chainstate& active_chainstate = chainman.ActiveChainstate();

// Loop through txids and try to find which block they're in. Exit loop once a block is found.
for (const auto& tx : setTxids) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/coinstatsindex_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
// make sure index is not corrupted and is able to reload.
BOOST_FIXTURE_TEST_CASE(coinstatsindex_unclean_shutdown, TestChain100Setup)
{
CChainState& chainstate = Assert(m_node.chainman)->ActiveChainstate();
Chainstate& chainstate = Assert(m_node.chainman)->ActiveChainstate();
const CChainParams& params = Params();
{
CoinStatsIndex index{interfaces::MakeChain(m_node), 1 << 20};
Expand Down
Loading

0 comments on commit 00eeb31

Please sign in to comment.