Bitcoin Core 30.99.0
P2P Digital Currency
base.cpp
Go to the documentation of this file.
1// Copyright (c) 2017-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <index/base.h>
6
7#include <chain.h>
8#include <common/args.h>
9#include <dbwrapper.h>
10#include <interfaces/chain.h>
11#include <interfaces/types.h>
12#include <kernel/chain.h>
13#include <logging.h>
14#include <node/abort.h>
15#include <node/blockstorage.h>
16#include <node/context.h>
17#include <node/database_args.h>
18#include <node/interface_ui.h>
19#include <primitives/block.h>
20#include <sync.h>
21#include <tinyformat.h>
22#include <uint256.h>
23#include <undo.h>
24#include <util/fs.h>
25#include <util/string.h>
26#include <util/thread.h>
27#include <util/threadinterrupt.h>
28#include <util/time.h>
29#include <util/translation.h>
30#include <validation.h>
31#include <validationinterface.h>
32
33#include <cassert>
34#include <compare>
35#include <cstdint>
36#include <memory>
37#include <optional>
38#include <span>
39#include <stdexcept>
40#include <string>
41#include <thread>
42#include <utility>
43#include <vector>
44
45constexpr uint8_t DB_BEST_BLOCK{'B'};
46
47constexpr auto SYNC_LOG_INTERVAL{30s};
49
50template <typename... Args>
51void BaseIndex::FatalErrorf(util::ConstevalFormatString<sizeof...(Args)> fmt, const Args&... args)
52{
53 auto message = tfm::format(fmt, args...);
54 node::AbortNode(m_chain->context()->shutdown_request, m_chain->context()->exit_status, Untranslated(message), m_chain->context()->warnings.get());
55}
56
58{
59 CBlockLocator locator;
60 bool found = chain.findBlock(block_hash, interfaces::FoundBlock().locator(locator));
61 assert(found);
62 assert(!locator.IsNull());
63 return locator;
64}
65
66BaseIndex::DB::DB(const fs::path& path, size_t n_cache_size, bool f_memory, bool f_wipe, bool f_obfuscate) :
68 .path = path,
69 .cache_bytes = n_cache_size,
70 .memory_only = f_memory,
71 .wipe_data = f_wipe,
72 .obfuscate = f_obfuscate,
73 .options = [] { DBOptions options; node::ReadDatabaseArgs(gArgs, options); return options; }()}}
74{}
75
77{
78 bool success = Read(DB_BEST_BLOCK, locator);
79 if (!success) {
80 locator.SetNull();
81 }
82 return success;
83}
84
86{
87 batch.Write(DB_BEST_BLOCK, locator);
88}
89
90BaseIndex::BaseIndex(std::unique_ptr<interfaces::Chain> chain, std::string name)
91 : m_chain{std::move(chain)}, m_name{std::move(name)} {}
92
94{
95 Interrupt();
96 Stop();
97}
98
100{
102
103 // May need reset if index is being restarted.
105
106 // m_chainstate member gives indexing code access to node internals. It is
107 // removed in followup https://github.com/bitcoin/bitcoin/pull/24230
109 return &m_chain->context()->chainman->GetChainstateForIndexing());
110 // Register to validation interface before setting the 'm_synced' flag, so that
111 // callbacks are not missed once m_synced is true.
112 m_chain->context()->validation_signals->RegisterValidationInterface(this);
113
114 CBlockLocator locator;
115 if (!GetDB().ReadBestBlock(locator)) {
116 locator.SetNull();
117 }
118
119 LOCK(cs_main);
120 CChain& index_chain = m_chainstate->m_chain;
121
122 if (locator.IsNull()) {
123 SetBestBlockIndex(nullptr);
124 } else {
125 // Setting the best block to the locator's top block. If it is not part of the
126 // best chain, we will rewind to the fork point during index sync
127 const CBlockIndex* locator_index{m_chainstate->m_blockman.LookupBlockIndex(locator.vHave.at(0))};
128 if (!locator_index) {
129 return InitError(Untranslated(strprintf("best block of %s not found. Please rebuild the index.", GetName())));
130 }
131 SetBestBlockIndex(locator_index);
132 }
133
134 // Child init
135 const CBlockIndex* start_block = m_best_block_index.load();
136 if (!CustomInit(start_block ? std::make_optional(interfaces::BlockRef{start_block->GetBlockHash(), start_block->nHeight}) : std::nullopt)) {
137 return false;
138 }
139
140 // Note: this will latch to true immediately if the user starts up with an empty
141 // datadir and an index enabled. If this is the case, indexation will happen solely
142 // via `BlockConnected` signals until, possibly, the next restart.
143 m_synced = start_block == index_chain.Tip();
144 m_init = true;
145 return true;
146}
147
149{
151
152 if (!pindex_prev) {
153 return chain.Genesis();
154 }
155
156 const CBlockIndex* pindex = chain.Next(pindex_prev);
157 if (pindex) {
158 return pindex;
159 }
160
161 // Since block is not in the chain, return the next block in the chain AFTER the last common ancestor.
162 // Caller will be responsible for rewinding back to the common ancestor.
163 return chain.Next(chain.FindFork(pindex_prev));
164}
165
166bool BaseIndex::ProcessBlock(const CBlockIndex* pindex, const CBlock* block_data)
167{
168 interfaces::BlockInfo block_info = kernel::MakeBlockInfo(pindex, block_data);
169
170 CBlock block;
171 if (!block_data) { // disk lookup if block data wasn't provided
172 if (!m_chainstate->m_blockman.ReadBlock(block, *pindex)) {
173 FatalErrorf("Failed to read block %s from disk",
174 pindex->GetBlockHash().ToString());
175 return false;
176 }
177 block_info.data = &block;
178 }
179
180 CBlockUndo block_undo;
181 if (CustomOptions().connect_undo_data) {
182 if (pindex->nHeight > 0 && !m_chainstate->m_blockman.ReadBlockUndo(block_undo, *pindex)) {
183 FatalErrorf("Failed to read undo block data %s from disk",
184 pindex->GetBlockHash().ToString());
185 return false;
186 }
187 block_info.undo_data = &block_undo;
188 }
189
190 if (!CustomAppend(block_info)) {
191 FatalErrorf("Failed to write block %s to index database",
192 pindex->GetBlockHash().ToString());
193 return false;
194 }
195
196 return true;
197}
198
200{
201 const CBlockIndex* pindex = m_best_block_index.load();
202 if (!m_synced) {
203 auto last_log_time{NodeClock::now()};
204 auto last_locator_write_time{last_log_time};
205 while (true) {
206 if (m_interrupt) {
207 LogInfo("%s: m_interrupt set; exiting ThreadSync", GetName());
208
209 SetBestBlockIndex(pindex);
210 // No need to handle errors in Commit. If it fails, the error will be already be
211 // logged. The best way to recover is to continue, as index cannot be corrupted by
212 // a missed commit to disk for an advanced index state.
213 Commit();
214 return;
215 }
216
217 const CBlockIndex* pindex_next = WITH_LOCK(cs_main, return NextSyncBlock(pindex, m_chainstate->m_chain));
218 // If pindex_next is null, it means pindex is the chain tip, so
219 // commit data indexed so far.
220 if (!pindex_next) {
221 SetBestBlockIndex(pindex);
222 // No need to handle errors in Commit. See rationale above.
223 Commit();
224
225 // If pindex is still the chain tip after committing, exit the
226 // sync loop. It is important for cs_main to be locked while
227 // setting m_synced = true, otherwise a new block could be
228 // attached while m_synced is still false, and it would not be
229 // indexed.
231 pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain);
232 if (!pindex_next) {
233 m_synced = true;
234 break;
235 }
236 }
237 if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {
238 FatalErrorf("Failed to rewind %s to a previous chain tip", GetName());
239 return;
240 }
241 pindex = pindex_next;
242
243
244 if (!ProcessBlock(pindex)) return; // error logged internally
245
246 auto current_time{NodeClock::now()};
247 if (current_time - last_log_time >= SYNC_LOG_INTERVAL) {
248 LogInfo("Syncing %s with block chain from height %d", GetName(), pindex->nHeight);
249 last_log_time = current_time;
250 }
251
252 if (current_time - last_locator_write_time >= SYNC_LOCATOR_WRITE_INTERVAL) {
253 SetBestBlockIndex(pindex);
254 last_locator_write_time = current_time;
255 // No need to handle errors in Commit. See rationale above.
256 Commit();
257 }
258 }
259 }
260
261 if (pindex) {
262 LogInfo("%s is enabled at height %d", GetName(), pindex->nHeight);
263 } else {
264 LogInfo("%s is enabled", GetName());
265 }
266}
267
269{
270 // Don't commit anything if we haven't indexed any block yet
271 // (this could happen if init is interrupted).
272 bool ok = m_best_block_index != nullptr;
273 if (ok) {
274 CDBBatch batch(GetDB());
275 ok = CustomCommit(batch);
276 if (ok) {
277 GetDB().WriteBestBlock(batch, GetLocator(*m_chain, m_best_block_index.load()->GetBlockHash()));
278 GetDB().WriteBatch(batch);
279 }
280 }
281 if (!ok) {
282 LogError("Failed to commit latest %s state", GetName());
283 return false;
284 }
285 return true;
286}
287
288bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip)
289{
290 assert(current_tip->GetAncestor(new_tip->nHeight) == new_tip);
291
292 CBlock block;
293 CBlockUndo block_undo;
294
295 for (const CBlockIndex* iter_tip = current_tip; iter_tip != new_tip; iter_tip = iter_tip->pprev) {
296 interfaces::BlockInfo block_info = kernel::MakeBlockInfo(iter_tip);
297 if (CustomOptions().disconnect_data) {
298 if (!m_chainstate->m_blockman.ReadBlock(block, *iter_tip)) {
299 LogError("Failed to read block %s from disk",
300 iter_tip->GetBlockHash().ToString());
301 return false;
302 }
303 block_info.data = &block;
304 }
305 if (CustomOptions().disconnect_undo_data && iter_tip->nHeight > 0) {
306 if (!m_chainstate->m_blockman.ReadBlockUndo(block_undo, *iter_tip)) {
307 return false;
308 }
309 block_info.undo_data = &block_undo;
310 }
311 if (!CustomRemove(block_info)) {
312 return false;
313 }
314 }
315
316 // Don't commit here - the committed index state must never be ahead of the
317 // flushed chainstate, otherwise unclean restarts would lead to index corruption.
318 // Pruning has a minimum of 288 blocks-to-keep and getting the index
319 // out of sync may be possible but a users fault.
320 // In case we reorg beyond the pruned depth, ReadBlock would
321 // throw and lead to a graceful shutdown
322 SetBestBlockIndex(new_tip);
323 return true;
324}
325
326void BaseIndex::BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
327{
328 // Ignore events from the assumed-valid chain; we will process its blocks
329 // (sequentially) after it is fully verified by the background chainstate. This
330 // is to avoid any out-of-order indexing.
331 //
332 // TODO at some point we could parameterize whether a particular index can be
333 // built out of order, but for now just do the conservative simple thing.
334 if (role == ChainstateRole::ASSUMEDVALID) {
335 return;
336 }
337
338 // Ignore BlockConnected signals until we have fully indexed the chain.
339 if (!m_synced) {
340 return;
341 }
342
343 const CBlockIndex* best_block_index = m_best_block_index.load();
344 if (!best_block_index) {
345 if (pindex->nHeight != 0) {
346 FatalErrorf("First block connected is not the genesis block (height=%d)",
347 pindex->nHeight);
348 return;
349 }
350 } else {
351 // Ensure block connects to an ancestor of the current best block. This should be the case
352 // most of the time, but may not be immediately after the sync thread catches up and sets
353 // m_synced. Consider the case where there is a reorg and the blocks on the stale branch are
354 // in the ValidationInterface queue backlog even after the sync thread has caught up to the
355 // new chain tip. In this unlikely event, log a warning and let the queue clear.
356 if (best_block_index->GetAncestor(pindex->nHeight - 1) != pindex->pprev) {
357 LogWarning("Block %s does not connect to an ancestor of "
358 "known best chain (tip=%s); not updating index",
359 pindex->GetBlockHash().ToString(),
360 best_block_index->GetBlockHash().ToString());
361 return;
362 }
363 if (best_block_index != pindex->pprev && !Rewind(best_block_index, pindex->pprev)) {
364 FatalErrorf("Failed to rewind %s to a previous chain tip",
365 GetName());
366 return;
367 }
368 }
369
370 // Dispatch block to child class; errors are logged internally and abort the node.
371 if (ProcessBlock(pindex, block.get())) {
372 // Setting the best block index is intentionally the last step of this
373 // function, so BlockUntilSyncedToCurrentChain callers waiting for the
374 // best block index to be updated can rely on the block being fully
375 // processed, and the index object being safe to delete.
376 SetBestBlockIndex(pindex);
377 }
378}
379
381{
382 // Ignore events from the assumed-valid chain; we will process its blocks
383 // (sequentially) after it is fully verified by the background chainstate.
384 if (role == ChainstateRole::ASSUMEDVALID) {
385 return;
386 }
387
388 if (!m_synced) {
389 return;
390 }
391
392 const uint256& locator_tip_hash = locator.vHave.front();
393 const CBlockIndex* locator_tip_index;
394 {
395 LOCK(cs_main);
396 locator_tip_index = m_chainstate->m_blockman.LookupBlockIndex(locator_tip_hash);
397 }
398
399 if (!locator_tip_index) {
400 FatalErrorf("First block (hash=%s) in locator was not found",
401 locator_tip_hash.ToString());
402 return;
403 }
404
405 // This checks that ChainStateFlushed callbacks are received after BlockConnected. The check may fail
406 // immediately after the sync thread catches up and sets m_synced. Consider the case where
407 // there is a reorg and the blocks on the stale branch are in the ValidationInterface queue
408 // backlog even after the sync thread has caught up to the new chain tip. In this unlikely
409 // event, log a warning and let the queue clear.
410 const CBlockIndex* best_block_index = m_best_block_index.load();
411 if (best_block_index->GetAncestor(locator_tip_index->nHeight) != locator_tip_index) {
412 LogWarning("Locator contains block (hash=%s) not on known best "
413 "chain (tip=%s); not writing index locator",
414 locator_tip_hash.ToString(),
415 best_block_index->GetBlockHash().ToString());
416 return;
417 }
418
419 // No need to handle errors in Commit. If it fails, the error will be already be logged. The
420 // best way to recover is to continue, as index cannot be corrupted by a missed commit to disk
421 // for an advanced index state.
422 Commit();
423}
424
425bool BaseIndex::BlockUntilSyncedToCurrentChain() const
426{
428
429 if (!m_synced) {
430 return false;
431 }
432
433 {
434 // Skip the queue-draining stuff if we know we're caught up with
435 // m_chain.Tip().
436 LOCK(cs_main);
437 const CBlockIndex* chain_tip = m_chainstate->m_chain.Tip();
438 const CBlockIndex* best_block_index = m_best_block_index.load();
439 if (best_block_index->GetAncestor(chain_tip->nHeight) == chain_tip) {
440 return true;
441 }
442 }
443
444 LogInfo("%s is catching up on block notifications", GetName());
445 m_chain->context()->validation_signals->SyncWithValidationInterfaceQueue();
446 return true;
447}
448
450{
451 m_interrupt();
452}
453
455{
456 if (!m_init) throw std::logic_error("Error: Cannot start a non-initialized index");
457
458 m_thread_sync = std::thread(&util::TraceThread, GetName(), [this] { Sync(); });
459 return true;
460}
461
463{
464 if (m_chain->context()->validation_signals) {
465 m_chain->context()->validation_signals->UnregisterValidationInterface(this);
466 }
467
468 if (m_thread_sync.joinable()) {
469 m_thread_sync.join();
470 }
471}
472
474{
475 IndexSummary summary{};
476 summary.name = GetName();
477 summary.synced = m_synced;
478 if (const auto& pindex = m_best_block_index.load()) {
479 summary.best_block_height = pindex->nHeight;
480 summary.best_block_hash = pindex->GetBlockHash();
481 } else {
482 summary.best_block_height = 0;
483 summary.best_block_hash = m_chain->getBlockHash(0);
484 }
485 return summary;
486}
487
489{
491
492 if (AllowPrune() && block) {
493 node::PruneLockInfo prune_lock;
494 prune_lock.height_first = block->nHeight;
495 WITH_LOCK(::cs_main, m_chainstate->m_blockman.UpdatePruneLock(GetName(), prune_lock));
496 }
497
498 // Intentionally set m_best_block_index as the last step in this function,
499 // after updating prune locks above, and after making any other references
500 // to *this, so the BlockUntilSyncedToCurrentChain function (which checks
501 // m_best_block_index as an optimization) can be used to wait for the last
502 // BlockConnected notification and safely assume that prune locks are
503 // updated and that the index object is safe to delete.
504 m_best_block_index = block;
505}
ArgsManager gArgs
Definition: args.cpp:40
static const CBlockIndex * NextSyncBlock(const CBlockIndex *pindex_prev, CChain &chain) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: base.cpp:148
constexpr uint8_t DB_BEST_BLOCK
Definition: base.cpp:45
constexpr auto SYNC_LOCATOR_WRITE_INTERVAL
Definition: base.cpp:48
constexpr auto SYNC_LOG_INTERVAL
Definition: base.cpp:47
CBlockLocator GetLocator(interfaces::Chain &chain, const uint256 &block_hash)
Definition: base.cpp:57
ArgsManager & args
Definition: bitcoind.cpp:277
void WriteBestBlock(CDBBatch &batch, const CBlockLocator &locator)
Write block locator of the chain that the index is in sync with.
Definition: base.cpp:85
DB(const fs::path &path, size_t n_cache_size, bool f_memory=false, bool f_wipe=false, bool f_obfuscate=false)
Definition: base.cpp:66
bool ReadBestBlock(CBlockLocator &locator) const
Read block locator of the chain that the index is in sync with.
Definition: base.cpp:76
void Stop()
Stops the instance from staying in sync with blockchain updates.
Definition: base.cpp:462
virtual bool CustomInit(const std::optional< interfaces::BlockRef > &block)
Initialize internal state from the database and block index.
Definition: base.h:128
void SetBestBlockIndex(const CBlockIndex *block)
Update the internal best block index as well as the prune lock.
Definition: base.cpp:488
bool Init()
Initializes the sync state and registers the instance to the validation interface so that it stays in...
Definition: base.cpp:99
virtual ~BaseIndex()
Destructor interrupts sync thread if running and blocks until it exits.
Definition: base.cpp:93
virtual bool CustomCommit(CDBBatch &batch)
Virtual method called internally by Commit that can be overridden to atomically commit more index sta...
Definition: base.h:135
const std::string & GetName() const LIFETIMEBOUND
Get the name of the index for display in logs.
Definition: base.h:151
bool BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void Interrupt()
Blocks the current thread until the index is caught up to the current state of the block chain.
Definition: base.cpp:449
virtual bool AllowPrune() const =0
void BlockConnected(ChainstateRole role, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex) override
Notifies listeners of a block being connected.
Definition: base.cpp:326
std::atomic< bool > m_synced
Whether the index is in sync with the main chain.
Definition: base.h:87
CThreadInterrupt m_interrupt
Definition: base.h:93
BaseIndex(std::unique_ptr< interfaces::Chain > chain, std::string name)
Definition: base.cpp:90
IndexSummary GetSummary() const
Get a summary of the index and its state.
Definition: base.cpp:473
const std::string m_name
Definition: base.h:118
virtual DB & GetDB() const =0
void Sync()
Sync the index with the block index starting from the current best block.
Definition: base.cpp:199
std::thread m_thread_sync
Definition: base.h:92
bool Commit()
Write the current index state (eg.
Definition: base.cpp:268
virtual interfaces::Chain::NotifyOptions CustomOptions()
Return custom notification options for index.
Definition: base.h:125
bool ProcessBlock(const CBlockIndex *pindex, const CBlock *block_data=nullptr)
Definition: base.cpp:166
void FatalErrorf(util::ConstevalFormatString< sizeof...(Args)> fmt, const Args &... args)
Definition: base.cpp:51
Chainstate * m_chainstate
Definition: base.h:117
bool Rewind(const CBlockIndex *current_tip, const CBlockIndex *new_tip)
Loop over disconnected blocks and call CustomRemove.
Definition: base.cpp:288
virtual bool CustomRemove(const interfaces::BlockInfo &block)
Rewind index by one block during a chain reorg.
Definition: base.h:138
bool StartBackgroundSync()
Starts the initial sync process on a background thread.
Definition: base.cpp:454
void ChainStateFlushed(ChainstateRole role, const CBlockLocator &locator) override
Notifies listeners of the new active block chain on-disk.
Definition: base.cpp:380
std::unique_ptr< interfaces::Chain > m_chain
Definition: base.h:116
std::atomic< bool > m_init
Whether the index has been initialized or not.
Definition: base.h:79
std::atomic< const CBlockIndex * > m_best_block_index
The last block in the chain that the index is in sync with.
Definition: base.h:90
virtual bool CustomAppend(const interfaces::BlockInfo &block)
Write update index entries for a newly connected block.
Definition: base.h:131
Definition: block.h:69
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:103
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: chain.h:109
uint256 GetBlockHash() const
Definition: chain.h:207
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
Definition: chain.cpp:110
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:115
Undo information for a CBlock.
Definition: undo.h:63
An in-memory indexed chain of blocks.
Definition: chain.h:381
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:397
Batch of changes queued to be written to a CDBWrapper.
Definition: dbwrapper.h:72
void Write(const K &key, const V &value)
Definition: dbwrapper.h:96
void WriteBatch(CDBBatch &batch, bool fSync=false)
Definition: dbwrapper.cpp:277
virtual void reset()
Reset to an non-interrupted state.
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:614
node::BlockManager & m_blockman
Reference to a BlockManager instance which itself is shared across all Chainstate instances.
Definition: validation.h:569
std::string ToString() const
Definition: uint256.cpp:21
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:131
virtual bool findBlock(const uint256 &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
Helper for findBlock to selectively return pieces of block data.
Definition: chain.h:50
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool ReadBlockUndo(CBlockUndo &blockundo, const CBlockIndex &index) const
bool ReadBlock(CBlock &block, const FlatFilePos &pos, const std::optional< uint256 > &expected_hash) const
Functions for disk access for blocks.
bool IsPruneMode() const
Whether running in -prune mode.
Definition: blockstorage.h:391
256-bit opaque blob.
Definition: uint256.h:196
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:8
bool InitError(const bilingual_str &str)
Show error message.
ChainstateRole
This enum describes the various roles a specific Chainstate instance can take.
Definition: chain.h:25
#define LogWarning(...)
Definition: logging.h:369
#define LogInfo(...)
Definition: logging.h:368
#define LogError(...)
Definition: logging.h:370
interfaces::BlockInfo MakeBlockInfo(const CBlockIndex *index, const CBlock *data)
Return data from block index.
Definition: chain.cpp:14
void AbortNode(const std::function< bool()> &shutdown_request, std::atomic< int > &exit_status, const bilingual_str &message, node::Warnings *warnings)
Definition: abort.cpp:18
void ReadDatabaseArgs(const ArgsManager &args, DBOptions &options)
void format(std::ostream &out, FormatStringCheck< sizeof...(Args)> fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
Definition: tinyformat.h:1079
void TraceThread(std::string_view thread_name, std::function< void()> thread_func)
A wrapper for do-something-once thread functions.
Definition: thread.cpp:16
const char * name
Definition: rest.cpp:48
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition: block.h:124
std::vector< uint256 > vHave
Definition: block.h:134
bool IsNull() const
Definition: block.h:152
void SetNull()
Definition: block.h:147
User-controlled performance and debug options.
Definition: dbwrapper.h:27
Application-specific storage settings.
Definition: dbwrapper.h:33
std::string name
Definition: base.h:31
static time_point now() noexcept
Return current system time or mocked time, if set.
Definition: time.cpp:26
Block data sent with blockConnected, blockDisconnected notifications.
Definition: chain.h:80
const CBlock * data
Definition: chain.h:86
const CBlockUndo * undo_data
Definition: chain.h:87
Hash/height pair to help track and identify blocks.
Definition: types.h:13
A wrapper for a compile-time partially validated format string.
Definition: string.h:92
#define AssertLockNotHeld(cs)
Definition: sync.h:142
#define LOCK(cs)
Definition: sync.h:259
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:290
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1172
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:82
AssertLockHeld(pool.cs)
assert(!tx.IsCoinBase())