Skip to content

Commit 50b6533

Browse files
committed
scripted-diff: Rename SetBestChain callback ChainStateFlushed
This much more accurately captures the meaning of the callback. -BEGIN VERIFY SCRIPT- sed -i 's/SetBestChain/ChainStateFlushed/g' src/validationinterface.h src/validationinterface.cpp src/wallet/wallet.h src/wallet/wallet.cpp src/validation.cpp src/index/txindex.h src/index/txindex.cpp -END VERIFY SCRIPT-
1 parent 17266a1 commit 50b6533

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

src/index/txindex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void TxIndex::BlockConnected(const std::shared_ptr<const CBlock>& block, const C
192192
}
193193
}
194194

195-
void TxIndex::SetBestChain(const CBlockLocator& locator)
195+
void TxIndex::ChainStateFlushed(const CBlockLocator& locator)
196196
{
197197
if (!m_synced) {
198198
return;
@@ -211,7 +211,7 @@ void TxIndex::SetBestChain(const CBlockLocator& locator)
211211
return;
212212
}
213213

214-
// This checks that SetBestChain callbacks are received after BlockConnected. The check may fail
214+
// This checks that ChainStateFlushed callbacks are received after BlockConnected. The check may fail
215215
// immediately after the the sync thread catches up and sets m_synced. Consider the case where
216216
// there is a reorg and the blocks on the stale branch are in the ValidationInterface queue
217217
// backlog even after the sync thread has caught up to the new chain tip. In this unlikely

src/index/txindex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TxIndex final : public CValidationInterface
5555
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex,
5656
const std::vector<CTransactionRef>& txn_conflicted) override;
5757

58-
void SetBestChain(const CBlockLocator& locator) override;
58+
void ChainStateFlushed(const CBlockLocator& locator) override;
5959

6060
public:
6161
/// Constructs the TxIndex, which becomes available to be queried.

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,7 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
21602160
}
21612161
if (fDoFullFlush || ((mode == FlushStateMode::ALWAYS || mode == FlushStateMode::PERIODIC) && nNow > nLastSetChain + (int64_t)DATABASE_WRITE_INTERVAL * 1000000)) {
21622162
// Update best block in wallet (so we can detect restored wallets).
2163-
GetMainSignals().SetBestChain(chainActive.GetLocator());
2163+
GetMainSignals().ChainStateFlushed(chainActive.GetLocator());
21642164
nLastSetChain = nNow;
21652165
}
21662166
} catch (const std::runtime_error& e) {

src/validationinterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct MainSignalsInstance {
2525
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef>&)> BlockConnected;
2626
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &)> BlockDisconnected;
2727
boost::signals2::signal<void (const CTransactionRef &)> TransactionRemovedFromMempool;
28-
boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
28+
boost::signals2::signal<void (const CBlockLocator &)> ChainStateFlushed;
2929
boost::signals2::signal<void (const uint256 &)> Inventory;
3030
boost::signals2::signal<void (int64_t nBestBlockTime, CConnman* connman)> Broadcast;
3131
boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
@@ -80,7 +80,7 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
8080
g_signals.m_internals->BlockConnected.connect(boost::bind(&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
8181
g_signals.m_internals->BlockDisconnected.connect(boost::bind(&CValidationInterface::BlockDisconnected, pwalletIn, _1));
8282
g_signals.m_internals->TransactionRemovedFromMempool.connect(boost::bind(&CValidationInterface::TransactionRemovedFromMempool, pwalletIn, _1));
83-
g_signals.m_internals->SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
83+
g_signals.m_internals->ChainStateFlushed.connect(boost::bind(&CValidationInterface::ChainStateFlushed, pwalletIn, _1));
8484
g_signals.m_internals->Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
8585
g_signals.m_internals->Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2));
8686
g_signals.m_internals->BlockChecked.connect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2));
@@ -91,7 +91,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
9191
g_signals.m_internals->BlockChecked.disconnect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2));
9292
g_signals.m_internals->Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2));
9393
g_signals.m_internals->Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
94-
g_signals.m_internals->SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
94+
g_signals.m_internals->ChainStateFlushed.disconnect(boost::bind(&CValidationInterface::ChainStateFlushed, pwalletIn, _1));
9595
g_signals.m_internals->TransactionAddedToMempool.disconnect(boost::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, _1));
9696
g_signals.m_internals->BlockConnected.disconnect(boost::bind(&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
9797
g_signals.m_internals->BlockDisconnected.disconnect(boost::bind(&CValidationInterface::BlockDisconnected, pwalletIn, _1));
@@ -107,7 +107,7 @@ void UnregisterAllValidationInterfaces() {
107107
g_signals.m_internals->BlockChecked.disconnect_all_slots();
108108
g_signals.m_internals->Broadcast.disconnect_all_slots();
109109
g_signals.m_internals->Inventory.disconnect_all_slots();
110-
g_signals.m_internals->SetBestChain.disconnect_all_slots();
110+
g_signals.m_internals->ChainStateFlushed.disconnect_all_slots();
111111
g_signals.m_internals->TransactionAddedToMempool.disconnect_all_slots();
112112
g_signals.m_internals->BlockConnected.disconnect_all_slots();
113113
g_signals.m_internals->BlockDisconnected.disconnect_all_slots();
@@ -166,9 +166,9 @@ void CMainSignals::BlockDisconnected(const std::shared_ptr<const CBlock> &pblock
166166
});
167167
}
168168

169-
void CMainSignals::SetBestChain(const CBlockLocator &locator) {
169+
void CMainSignals::ChainStateFlushed(const CBlockLocator &locator) {
170170
m_internals->m_schedulerClient.AddToProcessQueue([locator, this] {
171-
m_internals->SetBestChain(locator);
171+
m_internals->ChainStateFlushed(locator);
172172
});
173173
}
174174

src/validationinterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CValidationInterface {
101101
*
102102
* Called on a background thread.
103103
*/
104-
virtual void SetBestChain(const CBlockLocator &locator) {}
104+
virtual void ChainStateFlushed(const CBlockLocator &locator) {}
105105
/**
106106
* Notifies listeners about an inventory item being seen on the network.
107107
*
@@ -157,7 +157,7 @@ class CMainSignals {
157157
void TransactionAddedToMempool(const CTransactionRef &);
158158
void BlockConnected(const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::shared_ptr<const std::vector<CTransactionRef>> &);
159159
void BlockDisconnected(const std::shared_ptr<const CBlock> &);
160-
void SetBestChain(const CBlockLocator &);
160+
void ChainStateFlushed(const CBlockLocator &);
161161
void Inventory(const uint256 &);
162162
void Broadcast(int64_t nBestBlockTime, CConnman* connman);
163163
void BlockChecked(const CBlock&, const CValidationState&);

src/wallet/wallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
447447
return false;
448448
}
449449

450-
void CWallet::SetBestChain(const CBlockLocator& loc)
450+
void CWallet::ChainStateFlushed(const CBlockLocator& loc)
451451
{
452452
WalletBatch batch(*database);
453453
batch.WriteBestBlock(loc);
@@ -4032,7 +4032,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
40324032
return nullptr;
40334033
}
40344034

4035-
walletInstance->SetBestChain(chainActive.GetLocator());
4035+
walletInstance->ChainStateFlushed(chainActive.GetLocator());
40364036
} else if (gArgs.IsArgSet("-usehd")) {
40374037
bool useHD = gArgs.GetBoolArg("-usehd", true);
40384038
if (walletInstance->IsHDEnabled() && !useHD) {
@@ -4174,7 +4174,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
41744174
walletInstance->ScanForWalletTransactions(pindexRescan, nullptr, reserver, true);
41754175
}
41764176
LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);
4177-
walletInstance->SetBestChain(chainActive.GetLocator());
4177+
walletInstance->ChainStateFlushed(chainActive.GetLocator());
41784178
walletInstance->database->IncrementUpdateCounter();
41794179

41804180
// Restore wallet transaction metadata after -zapwallettxes=1

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
10131013
bool IsAllFromMe(const CTransaction& tx, const isminefilter& filter) const;
10141014
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
10151015
CAmount GetChange(const CTransaction& tx) const;
1016-
void SetBestChain(const CBlockLocator& loc) override;
1016+
void ChainStateFlushed(const CBlockLocator& loc) override;
10171017

10181018
DBErrors LoadWallet(bool& fFirstRunRet);
10191019
DBErrors ZapWalletTx(std::vector<CWalletTx>& vWtx);

0 commit comments

Comments
 (0)