mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Reimplement CBlockLocator's chain-related logic in CChain.
This removes a few unused CBlockLocator methods, and moves the construction and fork-finding logic to CChain (which can do these more efficiently, as it has a height-indexable chain available). It also makes CBlockLocator independent from the validation code.
This commit is contained in:
committed by
Pieter Wuille
parent
b2ba55c42b
commit
e4daecda0b
@@ -116,7 +116,7 @@ void Shutdown()
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (pwalletMain)
|
||||
pwalletMain->SetBestChain(CBlockLocator(chainActive.Tip()));
|
||||
pwalletMain->SetBestChain(chainActive.GetLocator());
|
||||
if (pblocktree)
|
||||
pblocktree->Flush();
|
||||
if (pcoinsTip)
|
||||
@@ -912,7 +912,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
strErrors << _("Cannot write default address") << "\n";
|
||||
}
|
||||
|
||||
pwalletMain->SetBestChain(CBlockLocator(chainActive.Tip()));
|
||||
pwalletMain->SetBestChain(chainActive.GetLocator());
|
||||
}
|
||||
|
||||
LogPrintf("%s", strErrors.str().c_str());
|
||||
@@ -928,7 +928,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
CWalletDB walletdb(strWalletFile);
|
||||
CBlockLocator locator;
|
||||
if (walletdb.ReadBestBlock(locator))
|
||||
pindexRescan = locator.GetBlockIndex();
|
||||
pindexRescan = chainActive.FindFork(locator);
|
||||
else
|
||||
pindexRescan = chainActive.Genesis();
|
||||
}
|
||||
@@ -939,7 +939,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
nStart = GetTimeMillis();
|
||||
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
|
||||
LogPrintf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
pwalletMain->SetBestChain(CBlockLocator(chainActive.Tip()));
|
||||
pwalletMain->SetBestChain(chainActive.GetLocator());
|
||||
nWalletDBUpdated++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user