mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02: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:
parent
b2ba55c42b
commit
e4daecda0b
5 changed files with 63 additions and 117 deletions
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue