Bitcoin Core  25.99.0
P2P Digital Currency
Go to the documentation of this file.
1 // Copyright (c) 2020-2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or
5 #include <test/util/index.h>
7 #include <index/base.h>
8 #include <shutdown.h>
9 #include <util/check.h>
10 #include <util/time.h>
12 void IndexWaitSynced(const BaseIndex& index)
13 {
14  while (!index.BlockUntilSyncedToCurrentChain()) {
15  // Assert shutdown was not requested to abort the test, instead of looping forever, in case
16  // there was an unexpected error in the index that caused it to stop syncing and request a shutdown.
19  UninterruptibleSleep(100ms);
20  }
21  assert(index.GetSummary().synced);
22 }
#define Assert(val)
Identity function.
Definition: check.h:73
Base class for indices of blockchain data.
Definition: base.h:35
IndexSummary GetSummary() const
Get a summary of the index and its state.
Definition: base.cpp:384
void IndexWaitSynced(const BaseIndex &index)
Block until the index is synced to the current chain.
Definition: index.cpp:12
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
Definition: shutdown.cpp:31
bool synced
Definition: base.h:24
void UninterruptibleSleep(const std::chrono::microseconds &n)
Definition: time.cpp:23