Skip to content

Commit 00eeb31

Browse files
jamesobMacroFake
and
MacroFake
committed
scripted-diff: rename CChainState -> Chainstate
-BEGIN VERIFY SCRIPT- sed -i 's/CChainState/Chainstate/g' $(git grep -l CChainState ':(exclude)doc/release-notes*') -END VERIFY SCRIPT- Co-authored-by: MacroFake <[email protected]>
1 parent 37095c7 commit 00eeb31

33 files changed

+154
-154
lines changed

doc/design/assumeutxo.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ be of use.
4141

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

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

5454
### "Normal" operation via initial block download
5555

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

doc/developer-notes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ void CTxMemPool::UpdateTransactionsFromBlock(...)
962962

963963
```C++
964964
// validation.h
965-
class CChainState
965+
class Chainstate
966966
{
967967
protected:
968968
...
@@ -983,7 +983,7 @@ public:
983983
}
984984

985985
// validation.cpp
986-
bool CChainState::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
986+
bool Chainstate::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
987987
{
988988
AssertLockNotHeld(m_chainstate_mutex);
989989
AssertLockNotHeld(::cs_main);

src/bitcoin-chainstate.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int main(int argc, char* argv[])
104104
}
105105
}
106106

107-
for (CChainState* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
107+
for (Chainstate* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
108108
BlockValidationState state;
109109
if (!chainstate->ActivateBestChain(state, nullptr)) {
110110
std::cerr << "Failed to connect best block (" << state.ToString() << ")" << std::endl;
@@ -253,7 +253,7 @@ int main(int argc, char* argv[])
253253
GetMainSignals().FlushBackgroundCallbacks();
254254
{
255255
LOCK(cs_main);
256-
for (CChainState* chainstate : chainman.GetAll()) {
256+
for (Chainstate* chainstate : chainman.GetAll()) {
257257
if (chainstate->CanFlushToDisk()) {
258258
chainstate->ForceFlushStateToDisk();
259259
chainstate->ResetCoinsViews();

src/index/base.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class CBlock;
1414
class CBlockIndex;
15-
class CChainState;
15+
class Chainstate;
1616
namespace interfaces {
1717
class Chain;
1818
} // namespace interfaces
@@ -94,7 +94,7 @@ class BaseIndex : public CValidationInterface
9494

9595
protected:
9696
std::unique_ptr<interfaces::Chain> m_chain;
97-
CChainState* m_chainstate{nullptr};
97+
Chainstate* m_chainstate{nullptr};
9898

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

src/init.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void Shutdown(NodeContext& node)
263263
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
264264
if (node.chainman) {
265265
LOCK(cs_main);
266-
for (CChainState* chainstate : node.chainman->GetAll()) {
266+
for (Chainstate* chainstate : node.chainman->GetAll()) {
267267
if (chainstate->CanFlushToDisk()) {
268268
chainstate->ForceFlushStateToDisk();
269269
}
@@ -294,7 +294,7 @@ void Shutdown(NodeContext& node)
294294

295295
if (node.chainman) {
296296
LOCK(cs_main);
297-
for (CChainState* chainstate : node.chainman->GetAll()) {
297+
for (Chainstate* chainstate : node.chainman->GetAll()) {
298298
if (chainstate->CanFlushToDisk()) {
299299
chainstate->ForceFlushStateToDisk();
300300
chainstate->ResetCoinsViews();
@@ -1532,7 +1532,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15321532
if (fPruneMode) {
15331533
if (!fReindex) {
15341534
LOCK(cs_main);
1535-
for (CChainState* chainstate : chainman.GetAll()) {
1535+
for (Chainstate* chainstate : chainman.GetAll()) {
15361536
uiInterface.InitMessage(_("Pruning blockstore…").translated);
15371537
chainstate->PruneAndFlush();
15381538
}

src/kernel/mempool_persist.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace kernel {
3737

3838
static const uint64_t MEMPOOL_DUMP_VERSION = 1;
3939

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

src/kernel/mempool_persist.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <fs.h>
99

10-
class CChainState;
10+
class Chainstate;
1111
class CTxMemPool;
1212

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

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

2525
} // namespace kernel

src/node/blockstorage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
882882
// We can't hold cs_main during ActivateBestChain even though we're accessing
883883
// the chainman unique_ptrs since ABC requires us not to be holding cs_main, so retrieve
884884
// the relevant pointers before the ABC call.
885-
for (CChainState* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
885+
for (Chainstate* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) {
886886
BlockValidationState state;
887887
if (!chainstate->ActivateBestChain(state, nullptr)) {
888888
LogPrintf("Failed to connect best block (%s)\n", state.ToString());

src/node/blockstorage.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CBlockFileInfo;
2626
class CBlockUndo;
2727
class CChain;
2828
class CChainParams;
29-
class CChainState;
29+
class Chainstate;
3030
class ChainstateManager;
3131
struct CCheckpointData;
3232
struct FlatFilePos;
@@ -75,12 +75,12 @@ struct PruneLockInfo {
7575
* Maintains a tree of blocks (stored in `m_block_index`) which is consulted
7676
* to determine where the most-work tip is.
7777
*
78-
* This data is used mostly in `CChainState` - information about, e.g.,
78+
* This data is used mostly in `Chainstate` - information about, e.g.,
7979
* candidate tips is not maintained here.
8080
*/
8181
class BlockManager
8282
{
83-
friend CChainState;
83+
friend Chainstate;
8484
friend ChainstateManager;
8585

8686
private:

src/node/chainstate.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace node {
2828
ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes,
2929
const ChainstateLoadOptions& options)
3030
{
31-
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
31+
auto is_coinsview_empty = [&](Chainstate* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
3232
return options.reindex || options.reindex_chainstate || chainstate->CoinsTip().GetBestBlock().IsNull();
3333
};
3434

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

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

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

158158
LOCK(cs_main);
159159

160-
for (CChainState* chainstate : chainman.GetAll()) {
160+
for (Chainstate* chainstate : chainman.GetAll()) {
161161
if (!is_coinsview_empty(chainstate)) {
162162
const CBlockIndex* tip = chainstate->m_chain.Tip();
163163
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {

src/node/miner.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ BlockAssembler::Options::Options()
6262
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
6363
}
6464

65-
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options)
65+
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
6666
: chainparams{chainstate.m_chainman.GetParams()},
6767
m_mempool(mempool),
6868
m_chainstate(chainstate)
@@ -87,7 +87,7 @@ static BlockAssembler::Options DefaultOptions()
8787
return options;
8888
}
8989

90-
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool)
90+
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool)
9191
: BlockAssembler(chainstate, mempool, DefaultOptions()) {}
9292

9393
void BlockAssembler::resetBlock()

src/node/miner.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class BlockAssembler
148148

149149
const CChainParams& chainparams;
150150
const CTxMemPool* const m_mempool;
151-
CChainState& m_chainstate;
151+
Chainstate& m_chainstate;
152152

153153
public:
154154
struct Options {
@@ -157,8 +157,8 @@ class BlockAssembler
157157
CFeeRate blockMinFeeRate;
158158
};
159159

160-
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool);
161-
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options);
160+
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool);
161+
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options);
162162

163163
/** Construct a new block template with coinbase to scriptPubKeyIn */
164164
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);

src/node/utxo_snapshot.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace node {
1313
//! Metadata describing a serialized version of a UTXO set from which an
14-
//! assumeutxo CChainState can be constructed.
14+
//! assumeutxo Chainstate can be constructed.
1515
class SnapshotMetadata
1616
{
1717
public:

src/rpc/blockchain.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ static RPCHelpMan pruneblockchain()
767767

768768
ChainstateManager& chainman = EnsureAnyChainman(request.context);
769769
LOCK(cs_main);
770-
CChainState& active_chainstate = chainman.ActiveChainstate();
770+
Chainstate& active_chainstate = chainman.ActiveChainstate();
771771
CChain& active_chain = active_chainstate.m_chain;
772772

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

909909
NodeContext& node = EnsureAnyNodeContext(request.context);
910910
ChainstateManager& chainman = EnsureChainman(node);
911-
CChainState& active_chainstate = chainman.ActiveChainstate();
911+
Chainstate& active_chainstate = chainman.ActiveChainstate();
912912
active_chainstate.ForceFlushStateToDisk();
913913

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

10501050
Coin coin;
1051-
CChainState& active_chainstate = chainman.ActiveChainstate();
1051+
Chainstate& active_chainstate = chainman.ActiveChainstate();
10521052
CCoinsViewCache* coins_view = &active_chainstate.CoinsTip();
10531053

10541054
if (fMempool) {
@@ -1105,7 +1105,7 @@ static RPCHelpMan verifychain()
11051105
ChainstateManager& chainman = EnsureAnyChainman(request.context);
11061106
LOCK(cs_main);
11071107

1108-
CChainState& active_chainstate = chainman.ActiveChainstate();
1108+
Chainstate& active_chainstate = chainman.ActiveChainstate();
11091109
return CVerifyDB().VerifyDB(
11101110
active_chainstate, chainman.GetParams().GetConsensus(), active_chainstate.CoinsTip(), check_level, check_depth);
11111111
},
@@ -1233,7 +1233,7 @@ RPCHelpMan getblockchaininfo()
12331233
const ArgsManager& args{EnsureAnyArgsman(request.context)};
12341234
ChainstateManager& chainman = EnsureAnyChainman(request.context);
12351235
LOCK(cs_main);
1236-
CChainState& active_chainstate = chainman.ActiveChainstate();
1236+
Chainstate& active_chainstate = chainman.ActiveChainstate();
12371237

12381238
const CBlockIndex& tip{*CHECK_NONFATAL(active_chainstate.m_chain.Tip())};
12391239
const int height{tip.nHeight};
@@ -1328,7 +1328,7 @@ static RPCHelpMan getdeploymentinfo()
13281328
{
13291329
const ChainstateManager& chainman = EnsureAnyChainman(request.context);
13301330
LOCK(cs_main);
1331-
const CChainState& active_chainstate = chainman.ActiveChainstate();
1331+
const Chainstate& active_chainstate = chainman.ActiveChainstate();
13321332

13331333
const CBlockIndex* blockindex;
13341334
if (request.params[0].isNull()) {
@@ -2148,7 +2148,7 @@ static RPCHelpMan scantxoutset()
21482148
{
21492149
ChainstateManager& chainman = EnsureChainman(node);
21502150
LOCK(cs_main);
2151-
CChainState& active_chainstate = chainman.ActiveChainstate();
2151+
Chainstate& active_chainstate = chainman.ActiveChainstate();
21522152
active_chainstate.ForceFlushStateToDisk();
21532153
pcursor = CHECK_NONFATAL(active_chainstate.CoinsDB().Cursor());
21542154
tip = CHECK_NONFATAL(active_chainstate.m_chain.Tip());
@@ -2328,7 +2328,7 @@ static RPCHelpMan dumptxoutset()
23282328

23292329
UniValue CreateUTXOSnapshot(
23302330
NodeContext& node,
2331-
CChainState& chainstate,
2331+
Chainstate& chainstate,
23322332
AutoFile& afile,
23332333
const fs::path& path,
23342334
const fs::path& temppath)

src/rpc/blockchain.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern RecursiveMutex cs_main;
2020

2121
class CBlock;
2222
class CBlockIndex;
23-
class CChainState;
23+
class Chainstate;
2424
class UniValue;
2525
namespace node {
2626
struct NodeContext;
@@ -54,7 +54,7 @@ void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES],
5454
*/
5555
UniValue CreateUTXOSnapshot(
5656
node::NodeContext& node,
57-
CChainState& chainstate,
57+
Chainstate& chainstate,
5858
AutoFile& afile,
5959
const fs::path& path,
6060
const fs::path& tmppath);

src/rpc/mempool.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static RPCHelpMan testmempoolaccept()
168168
NodeContext& node = EnsureAnyNodeContext(request.context);
169169
CTxMemPool& mempool = EnsureMemPool(node);
170170
ChainstateManager& chainman = EnsureChainman(node);
171-
CChainState& chainstate = chainman.ActiveChainstate();
171+
Chainstate& chainstate = chainman.ActiveChainstate();
172172
const PackageMempoolAcceptResult package_result = [&] {
173173
LOCK(::cs_main);
174174
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true);
@@ -810,7 +810,7 @@ static RPCHelpMan submitpackage()
810810

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

816816
// First catch any errors.

src/rpc/mining.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static RPCHelpMan getblocktemplate()
598598
std::string strMode = "template";
599599
UniValue lpval = NullUniValue;
600600
std::set<std::string> setClientRules;
601-
CChainState& active_chainstate = chainman.ActiveChainstate();
601+
Chainstate& active_chainstate = chainman.ActiveChainstate();
602602
CChain& active_chain = active_chainstate.m_chain;
603603
if (!request.params[0].isNull())
604604
{

src/rpc/rawtransaction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ using node::GetTransaction;
5151
using node::NodeContext;
5252
using node::PSBTAnalysis;
5353

54-
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, CChainState& active_chainstate)
54+
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, Chainstate& active_chainstate)
5555
{
5656
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
5757
//

src/rpc/txoutproof.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static RPCHelpMan gettxoutproof()
6666
}
6767
} else {
6868
LOCK(cs_main);
69-
CChainState& active_chainstate = chainman.ActiveChainstate();
69+
Chainstate& active_chainstate = chainman.ActiveChainstate();
7070

7171
// Loop through txids and try to find which block they're in. Exit loop once a block is found.
7272
for (const auto& tx : setTxids) {

src/test/coinstatsindex_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
8585
// make sure index is not corrupted and is able to reload.
8686
BOOST_FIXTURE_TEST_CASE(coinstatsindex_unclean_shutdown, TestChain100Setup)
8787
{
88-
CChainState& chainstate = Assert(m_node.chainman)->ActiveChainstate();
88+
Chainstate& chainstate = Assert(m_node.chainman)->ActiveChainstate();
8989
const CChainParams& params = Params();
9090
{
9191
CoinStatsIndex index{interfaces::MakeChain(m_node), 1 << 20};

0 commit comments

Comments
 (0)