Apply suggestions from code review

Co-authored-by: str4d <thestr4d@gmail.com>
Co-authored-by: ying tong <yingtong@z.cash>
This commit is contained in:
Kris Nuttycombe 2022-04-07 21:04:50 -06:00 committed by Kris Nuttycombe
parent 773c2b515a
commit f553ae3320
1 changed files with 13 additions and 9 deletions

View File

@ -606,7 +606,7 @@ void ThreadStartWalletNotifier()
{
CBlockIndex *pindexLastTip;
// However, if a wallet is enabled, we actually want to start notifying
// If the wallet is compiled in and enabled, we want to start notifying
// from the block which corresponds with the wallet's view of the chain
// tip. In particular, we want to handle the case where the node shuts
// down uncleanly, and on restart the chain's tip is potentially up to
@ -668,18 +668,22 @@ void ThreadStartWalletNotifier()
// more than 100 blocks behind pindexLastTip. This can occur if the node
// shuts down abruptly without being able to write out chainActive; the
// node writes chain data out roughly hourly, while the wallet writes it
// every 10 minutes. We need to wait for ThreadImport to catch up.
// every 10 minutes. We need to wait for ThreadImport to catch up, or any
// missing blocks to be fetched from peers.
while (true) {
boost::this_thread::interruption_point();
const CBlockIndex *pindexFork = chainActive.FindFork(pindexLastTip);
// We know we have the genesis block.
assert(pindexFork != nullptr);
if (pindexLastTip->nHeight < pindexFork->nHeight ||
pindexLastTip->nHeight - pindexFork->nHeight < 100)
{
break;
LOCK(cs_main);
const CBlockIndex *pindexFork = chainActive.FindFork(pindexLastTip);
// We know we have the genesis block.
assert(pindexFork != nullptr);
if (pindexLastTip->nHeight < pindexFork->nHeight ||
pindexLastTip->nHeight - pindexFork->nHeight < 100)
{
break;
}
}
if (timedOut()) {