wallet: Rename `CWallet::GetBestBlock` to `GetPersistedBestBlock`

This more accurately reflects its meaning, as it corresponds to the most
recently persisted best chain (i.e. the chain tip that the wallet will
return to on restart), rather than the chain tip to which the in-memory
wallet state has been synced.
This commit is contained in:
Jack Grigg 2022-04-04 17:39:53 +00:00
parent 3a1261efda
commit 098a70ed89
3 changed files with 10 additions and 6 deletions

View File

@ -1727,7 +1727,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (pwalletMain)
{
LOCK2(cs_main, pwalletMain->cs_wallet);
const auto walletBestBlock = pwalletMain->GetBestBlock();
const auto walletBestBlock = pwalletMain->GetPersistedBestBlock();
if (walletBestBlock != nullptr) {
pindexLastTip = walletBestBlock;
}

View File

@ -1501,7 +1501,7 @@ void CWallet::SetBestChain(const CBlockLocator& loc)
SetBestChainINTERNAL(walletdb, loc);
}
CBlockIndex* CWallet::GetBestBlock()
CBlockIndex* CWallet::GetPersistedBestBlock()
{
AssertLockHeld(cs_main);
AssertLockHeld(cs_wallet);

View File

@ -1806,11 +1806,15 @@ public:
/** Saves witness caches and best block locator to disk. */
void SetBestChain(const CBlockLocator& loc);
/**
* Returns the block index corresponding to the wallet's best block, or
* nullptr if the wallet's best block is not known to this node (e.g. if the
* wallet was transplanted from another node).
* Returns the block index corresponding to the wallet's most recently
* persisted best block. This is the state to which the wallet will revert
* if restarted immediately, and does not necessarily match the current
* in-memory state.
*
* Returns nullptr if the wallet's best block is not known to this node
* (e.g. if the wallet was transplanted from another node).
*/
CBlockIndex* GetBestBlock();
CBlockIndex* GetPersistedBestBlock();
std::set<std::pair<libzcash::SproutPaymentAddress, uint256>> GetSproutNullifiers(
const std::set<libzcash::SproutPaymentAddress>& addresses);