[wallet] Remove redundant initialization

Prior to this commit pindexRescan was initialized to a chainActive.Tip().
However, the value of pindexRescan set at time of initialization was never
read before pindexRescan was being set to either chainActive.Genesis()
(case 1), FindForkInGlobalIndex(chainActive, locator) (case 2) or
chainActive.Genesis() (case 3). Thus, the initialization was redundant.

This commit a.) removes the redundant initialization and b.) simplifies
this logic so that pindexRescan is initialized to chainActive.Genesis()
(case 1 and 3), and set to FindForkInGlobalIndex(chainActive, locator)
(case 2) as needed.
pull/365/head
practicalswift 8 years ago
parent 7e2a2212ec
commit 343ba8fef5

@ -3681,17 +3681,13 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
RegisterValidationInterface(walletInstance); RegisterValidationInterface(walletInstance);
CBlockIndex *pindexRescan = chainActive.Tip(); CBlockIndex *pindexRescan = chainActive.Genesis();
if (GetBoolArg("-rescan", false)) if (!GetBoolArg("-rescan", false))
pindexRescan = chainActive.Genesis();
else
{ {
CWalletDB walletdb(walletFile); CWalletDB walletdb(walletFile);
CBlockLocator locator; CBlockLocator locator;
if (walletdb.ReadBestBlock(locator)) if (walletdb.ReadBestBlock(locator))
pindexRescan = FindForkInGlobalIndex(chainActive, locator); pindexRescan = FindForkInGlobalIndex(chainActive, locator);
else
pindexRescan = chainActive.Genesis();
} }
if (chainActive.Tip() && chainActive.Tip() != pindexRescan) if (chainActive.Tip() && chainActive.Tip() != pindexRescan)
{ {

Loading…
Cancel
Save