Skip to content

Commit 16baf53

Browse files
glozowvijaydasmp
authored andcommitted
Merge bitcoin#24513: CChainState -> Chainstate
00eeb31 scripted-diff: rename CChainState -> Chainstate (James O'Beirne) Pull request description: Alright alright alright, I know: we hate refactors. We especially hate cosmetic refactors. Nobody knows better than I that changing broad swaths of code out from under our already-abused collaborators, only to send a cascade of rebase bankruptcies, is annoying at best and sadistic at worst. And for a rename! The indignation! But just for a second, imagine yourself. Programming `bitcoin/bitcoin`, on a sandy beach beneath a lapis lazuli sky. You go to type the name of what is probably the most commonly used data structure in the codebase, and you *only hit shift once*. What could you do in such a world? You could do anything. [The only limit is yourself.](https://zombo.com/) --- So maybe you like the idea of this patch but really don't want to deal with rebasing. You're in luck! Here're the commands that will bail you out of rebase bankruptcy: ```sh git rebase -i $(git merge-base HEAD master) \ -x 'sed -i "s/CChainState/Chainstate/g" $(git ls-files | grep -E ".*\.(py|cpp|h)$") && git commit --amend --no-edit' # <commit changed?> git add -u && git rebase --continue ``` --- ~~Anyway I'm not sure how serious I am about this, but I figured it was worth proposing.~~ I have decided I am very serious about this. Maybe we can have nice things every once in a while? ACKs for top commit: MarcoFalke: cr ACK 00eeb31 hebasto: ACK 00eeb31 glozow: ACK 00eeb31, thanks for being the one to propose this w0xlt: ACK bitcoin@00eeb31 Tree-SHA512: b828a99780614a9b74f7a9c347ce0687de6f8d75232840f5ffc26e02bbb25a3b1f5f9deabbe44f82ada01459586ee8452a3ee2da05d1b3c48558c8df6f49e1b1 Fixing CChainState Fixing CChainState in other places Fixing CChainState in other places Fixing CChainState in other places Fixing errors Fixing Build error Fixing alignment Missed blockchain.cpp file for CChainState conversion Signed-off-by: Shailendra Kumar Gupta <guptashail05@gmail.com>
1 parent 7e524b1 commit 16baf53

47 files changed

Lines changed: 206 additions & 205 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/design/assumeutxo.md

Lines changed: 2 additions & 2 deletions
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 dashd.
5959

doc/developer-notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void CTxMemPool::UpdateTransactionsFromBlock(...)
10341034

10351035
```C++
10361036
// validation.h
1037-
class CChainState
1037+
class Chainstate
10381038
{
10391039
protected:
10401040
...
@@ -1055,7 +1055,7 @@ public:
10551055
}
10561056

10571057
// validation.cpp
1058-
bool CChainState::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
1058+
bool Chainstate::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
10591059
{
10601060
AssertLockNotHeld(m_chainstate_mutex);
10611061
AssertLockNotHeld(::cs_main);

src/bench/load_external.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void LoadExternalBlockFile(benchmark::Bench& bench)
4848
fclose(file);
4949
}
5050

51-
CChainState& chainstate{testing_setup->m_node.chainman->ActiveChainstate()};
51+
Chainstate& chainstate{testing_setup->m_node.chainman->ActiveChainstate()};
5252
std::multimap<uint256, FlatFilePos> blocks_with_unknown_parent;
5353
FlatFilePos pos;
5454
bench.run([&] {

src/chainlock/signing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using node::ReadBlockFromDisk;
2121

2222
namespace chainlock {
23-
ChainLockSigner::ChainLockSigner(CChainState& chainstate, const chainlock::Chainlocks& chainlocks,
23+
ChainLockSigner::ChainLockSigner(Chainstate& chainstate, const chainlock::Chainlocks& chainlocks,
2424
ChainlockHandler& clhandler, const llmq::CInstantSendManager& isman,
2525
const llmq::CQuorumManager& qman, llmq::CSigningManager& sigman,
2626
llmq::CSigSharesManager& shareman, const CMasternodeSync& mn_sync) :

src/chainlock/signing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ChainlockHandler;
2626
class ChainLockSigner final : public llmq::CRecoveredSigsListener, public CValidationInterface
2727
{
2828
private:
29-
CChainState& m_chainstate;
29+
Chainstate& m_chainstate;
3030
const chainlock::Chainlocks& m_chainlocks;
3131
ChainlockHandler& m_clhandler;
3232
const llmq::CInstantSendManager& m_isman;
@@ -59,7 +59,7 @@ class ChainLockSigner final : public llmq::CRecoveredSigsListener, public CValid
5959
ChainLockSigner() = delete;
6060
ChainLockSigner(const ChainLockSigner&) = delete;
6161
ChainLockSigner& operator=(const ChainLockSigner&) = delete;
62-
explicit ChainLockSigner(CChainState& chainstate, const chainlock::Chainlocks& chainlocks,
62+
explicit ChainLockSigner(Chainstate& chainstate, const chainlock::Chainlocks& chainlocks,
6363
ChainlockHandler& clhandler, const llmq::CInstantSendManager& isman,
6464
const llmq::CQuorumManager& qman, llmq::CSigningManager& sigman,
6565
llmq::CSigSharesManager& shareman, const CMasternodeSync& mn_sync);

src/coinjoin/client.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ CCoinJoinClientManager::CCoinJoinClientManager(const std::shared_ptr<wallet::CWa
5555

5656
CCoinJoinClientManager::~CCoinJoinClientManager() = default;
5757

58-
void CCoinJoinClientManager::ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
58+
void CCoinJoinClientManager::ProcessMessage(CNode& peer, Chainstate& active_chainstate, CConnman& connman,
59+
const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
5960
{
6061
if (!CCoinJoinClientOptions::IsEnabled()) return;
6162
if (!m_mn_sync.IsBlockchainSynced()) return;
@@ -89,7 +90,7 @@ CCoinJoinClientSession::CCoinJoinClientSession(const std::shared_ptr<CWallet>& w
8990
m_isman{isman}
9091
{}
9192

92-
void CCoinJoinClientSession::ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
93+
void CCoinJoinClientSession::ProcessMessage(CNode& peer, Chainstate& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
9394
{
9495
if (!CCoinJoinClientOptions::IsEnabled()) return;
9596
if (!m_mn_sync.IsBlockchainSynced()) return;
@@ -444,7 +445,7 @@ void CCoinJoinClientSession::ProcessPoolStateUpdate(CCoinJoinStatusUpdate psssup
444445
// check it to make sure it's what we want, then sign it if we agree.
445446
// If we refuse to sign, it's possible we'll be charged collateral
446447
//
447-
bool CCoinJoinClientSession::SignFinalTransaction(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, const CTransaction& finalTransactionNew)
448+
bool CCoinJoinClientSession::SignFinalTransaction(CNode& peer, Chainstate& active_chainstate, CConnman& connman, const CTxMemPool& mempool, const CTransaction& finalTransactionNew)
448449
{
449450
if (!CCoinJoinClientOptions::IsEnabled()) return false;
450451

src/coinjoin/client.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
117117
void CompletedTransaction(PoolMessage nMessageID);
118118

119119
/// As a client, check and sign the final transaction
120-
bool SignFinalTransaction(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, const CTransaction& finalTransactionNew) EXCLUSIVE_LOCKS_REQUIRED(!cs_coinjoin);
120+
bool SignFinalTransaction(CNode& peer, Chainstate& active_chainstate, CConnman& connman, const CTxMemPool& mempool, const CTransaction& finalTransactionNew) EXCLUSIVE_LOCKS_REQUIRED(!cs_coinjoin);
121121

122122
void RelayIn(const CCoinJoinEntry& entry, CConnman& connman) const;
123123

@@ -128,7 +128,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
128128
CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
129129
const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman);
130130

131-
void ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv);
131+
void ProcessMessage(CNode& peer, Chainstate& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv);
132132

133133
void UnlockCoins();
134134

@@ -195,7 +195,7 @@ class CCoinJoinClientManager
195195
const llmq::CInstantSendManager& isman, CoinJoinQueueManager* queueman);
196196
~CCoinJoinClientManager();
197197

198-
void ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
198+
void ProcessMessage(CNode& peer, Chainstate& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
199199

200200
bool StartMixing();
201201
void StopMixing();

src/coinjoin/coinjoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ std::string CCoinJoinBaseSession::GetStateString() const
199199
}
200200
}
201201

202-
bool CCoinJoinBaseSession::IsValidInOuts(CChainState& active_chainstate, const llmq::CInstantSendManager& isman,
202+
bool CCoinJoinBaseSession::IsValidInOuts(Chainstate& active_chainstate, const llmq::CInstantSendManager& isman,
203203
const CTxMemPool& mempool, const std::vector<CTxIn>& vin,
204204
const std::vector<CTxOut>& vout, PoolMessage& nMessageIDRet,
205205
bool* fConsumeCollateralRet) const

src/coinjoin/coinjoin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include <univalue.h>
2727

28-
class CChainState;
28+
class Chainstate;
2929
class CBLSPublicKey;
3030
class CBlockIndex;
3131
class ChainstateManager;
@@ -304,7 +304,7 @@ class CCoinJoinBaseSession
304304

305305
virtual void SetNull() EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);
306306

307-
bool IsValidInOuts(CChainState& active_chainstate, const llmq::CInstantSendManager& isman,
307+
bool IsValidInOuts(Chainstate& active_chainstate, const llmq::CInstantSendManager& isman,
308308
const CTxMemPool& mempool, const std::vector<CTxIn>& vin, const std::vector<CTxOut>& vout,
309309
PoolMessage& nMessageIDRet, bool* fConsumeCollateralRet) const;
310310

src/coinjoin/walletman.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CJWalletManagerImpl final : public CJWalletManager
4040
public:
4141
bool hasQueue(const uint256& hash) const override;
4242
CCoinJoinClientManager* getClient(const std::string& name) override EXCLUSIVE_LOCKS_REQUIRED(!cs_wallet_manager_map);
43-
MessageProcessingResult processMessage(CNode& peer, CChainState& chainstate, CConnman& connman, CTxMemPool& mempool,
43+
MessageProcessingResult processMessage(CNode& peer, Chainstate& chainstate, CConnman& connman, CTxMemPool& mempool,
4444
std::string_view msg_type, CDataStream& vRecv) override EXCLUSIVE_LOCKS_REQUIRED(!cs_ProcessDSQueue, !cs_wallet_manager_map);
4545
std::optional<CCoinJoinQueue> getQueueFromHash(const uint256& hash) const override;
4646
std::optional<int> getQueueSize() const override;
@@ -202,7 +202,7 @@ void CJWalletManagerImpl::DoMaintenance(CConnman& connman)
202202
}
203203
}
204204

205-
MessageProcessingResult CJWalletManagerImpl::processMessage(CNode& pfrom, CChainState& chainstate, CConnman& connman,
205+
MessageProcessingResult CJWalletManagerImpl::processMessage(CNode& pfrom, Chainstate& chainstate, CConnman& connman,
206206
CTxMemPool& mempool, std::string_view msg_type,
207207
CDataStream& vRecv)
208208
{

0 commit comments

Comments
 (0)