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