Bitcoin Core 22.99.0
P2P Digital Currency
txdb.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2020 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include <txdb.h>
7
8#include <chain.h>
9#include <node/ui_interface.h>
10#include <pow.h>
11#include <random.h>
12#include <shutdown.h>
13#include <uint256.h>
14#include <util/system.h>
15#include <util/translation.h>
16#include <util/vector.h>
17
18#include <stdint.h>
19
20static constexpr uint8_t DB_COIN{'C'};
21static constexpr uint8_t DB_COINS{'c'};
22static constexpr uint8_t DB_BLOCK_FILES{'f'};
23static constexpr uint8_t DB_BLOCK_INDEX{'b'};
24
25static constexpr uint8_t DB_BEST_BLOCK{'B'};
26static constexpr uint8_t DB_HEAD_BLOCKS{'H'};
27static constexpr uint8_t DB_FLAG{'F'};
28static constexpr uint8_t DB_REINDEX_FLAG{'R'};
29static constexpr uint8_t DB_LAST_BLOCK{'l'};
30
31// Keys used in previous version that might still be found in the DB:
32static constexpr uint8_t DB_TXINDEX_BLOCK{'T'};
33// uint8_t DB_TXINDEX{'t'}
34
35std::optional<bilingual_str> CheckLegacyTxindex(CBlockTreeDB& block_tree_db)
36{
37 CBlockLocator ignored{};
38 if (block_tree_db.Read(DB_TXINDEX_BLOCK, ignored)) {
39 return _("The -txindex upgrade started by a previous version can not be completed. Restart with the previous version or run a full -reindex.");
40 }
41 bool txindex_legacy_flag{false};
42 block_tree_db.ReadFlag("txindex", txindex_legacy_flag);
43 if (txindex_legacy_flag) {
44 // Disable legacy txindex and warn once about occupied disk space
45 if (!block_tree_db.WriteFlag("txindex", false)) {
46 return Untranslated("Failed to write block index db flag 'txindex'='0'");
47 }
48 return _("The block index db contains a legacy 'txindex'. To clear the occupied disk space, run a full -reindex, otherwise ignore this error. This error message will not be displayed again.");
49 }
50 return std::nullopt;
51}
52
53namespace {
54
55struct CoinEntry {
56 COutPoint* outpoint;
57 uint8_t key;
58 explicit CoinEntry(const COutPoint* ptr) : outpoint(const_cast<COutPoint*>(ptr)), key(DB_COIN) {}
59
60 SERIALIZE_METHODS(CoinEntry, obj) { READWRITE(obj.key, obj.outpoint->hash, VARINT(obj.outpoint->n)); }
61};
62
63}
64
65CCoinsViewDB::CCoinsViewDB(fs::path ldb_path, size_t nCacheSize, bool fMemory, bool fWipe) :
66 m_db(std::make_unique<CDBWrapper>(ldb_path, nCacheSize, fMemory, fWipe, true)),
67 m_ldb_path(ldb_path),
68 m_is_memory(fMemory) { }
69
70void CCoinsViewDB::ResizeCache(size_t new_cache_size)
71{
72 // We can't do this operation with an in-memory DB since we'll lose all the coins upon
73 // reset.
74 if (!m_is_memory) {
75 // Have to do a reset first to get the original `m_db` state to release its
76 // filesystem lock.
77 m_db.reset();
78 m_db = std::make_unique<CDBWrapper>(
79 m_ldb_path, new_cache_size, m_is_memory, /*fWipe*/ false, /*obfuscate*/ true);
80 }
81}
82
83bool CCoinsViewDB::GetCoin(const COutPoint &outpoint, Coin &coin) const {
84 return m_db->Read(CoinEntry(&outpoint), coin);
85}
86
87bool CCoinsViewDB::HaveCoin(const COutPoint &outpoint) const {
88 return m_db->Exists(CoinEntry(&outpoint));
89}
90
92 uint256 hashBestChain;
93 if (!m_db->Read(DB_BEST_BLOCK, hashBestChain))
94 return uint256();
95 return hashBestChain;
96}
97
98std::vector<uint256> CCoinsViewDB::GetHeadBlocks() const {
99 std::vector<uint256> vhashHeadBlocks;
100 if (!m_db->Read(DB_HEAD_BLOCKS, vhashHeadBlocks)) {
101 return std::vector<uint256>();
102 }
103 return vhashHeadBlocks;
104}
105
106bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) {
107 CDBBatch batch(*m_db);
108 size_t count = 0;
109 size_t changed = 0;
110 size_t batch_size = (size_t)gArgs.GetIntArg("-dbbatchsize", nDefaultDbBatchSize);
111 int crash_simulate = gArgs.GetIntArg("-dbcrashratio", 0);
112 assert(!hashBlock.IsNull());
113
114 uint256 old_tip = GetBestBlock();
115 if (old_tip.IsNull()) {
116 // We may be in the middle of replaying.
117 std::vector<uint256> old_heads = GetHeadBlocks();
118 if (old_heads.size() == 2) {
119 assert(old_heads[0] == hashBlock);
120 old_tip = old_heads[1];
121 }
122 }
123
124 // In the first batch, mark the database as being in the middle of a
125 // transition from old_tip to hashBlock.
126 // A vector is used for future extensibility, as we may want to support
127 // interrupting after partial writes from multiple independent reorgs.
128 batch.Erase(DB_BEST_BLOCK);
129 batch.Write(DB_HEAD_BLOCKS, Vector(hashBlock, old_tip));
130
131 for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
132 if (it->second.flags & CCoinsCacheEntry::DIRTY) {
133 CoinEntry entry(&it->first);
134 if (it->second.coin.IsSpent())
135 batch.Erase(entry);
136 else
137 batch.Write(entry, it->second.coin);
138 changed++;
139 }
140 count++;
141 CCoinsMap::iterator itOld = it++;
142 mapCoins.erase(itOld);
143 if (batch.SizeEstimate() > batch_size) {
144 LogPrint(BCLog::COINDB, "Writing partial batch of %.2f MiB\n", batch.SizeEstimate() * (1.0 / 1048576.0));
145 m_db->WriteBatch(batch);
146 batch.Clear();
147 if (crash_simulate) {
148 static FastRandomContext rng;
149 if (rng.randrange(crash_simulate) == 0) {
150 LogPrintf("Simulating a crash. Goodbye.\n");
151 _Exit(0);
152 }
153 }
154 }
155 }
156
157 // In the last batch, mark the database as consistent with hashBlock again.
158 batch.Erase(DB_HEAD_BLOCKS);
159 batch.Write(DB_BEST_BLOCK, hashBlock);
160
161 LogPrint(BCLog::COINDB, "Writing final batch of %.2f MiB\n", batch.SizeEstimate() * (1.0 / 1048576.0));
162 bool ret = m_db->WriteBatch(batch);
163 LogPrint(BCLog::COINDB, "Committed %u changed transaction outputs (out of %u) to coin database...\n", (unsigned int)changed, (unsigned int)count);
164 return ret;
165}
166
168{
169 return m_db->EstimateSize(DB_COIN, uint8_t(DB_COIN + 1));
170}
171
172CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(gArgs.GetDataDirNet() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
173}
174
176 return Read(std::make_pair(DB_BLOCK_FILES, nFile), info);
177}
178
179bool CBlockTreeDB::WriteReindexing(bool fReindexing) {
180 if (fReindexing)
181 return Write(DB_REINDEX_FLAG, uint8_t{'1'});
182 else
183 return Erase(DB_REINDEX_FLAG);
184}
185
186void CBlockTreeDB::ReadReindexing(bool &fReindexing) {
187 fReindexing = Exists(DB_REINDEX_FLAG);
188}
189
191 return Read(DB_LAST_BLOCK, nFile);
192}
193
196{
197public:
198 // Prefer using CCoinsViewDB::Cursor() since we want to perform some
199 // cache warmup on instantiation.
200 CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256&hashBlockIn):
201 CCoinsViewCursor(hashBlockIn), pcursor(pcursorIn) {}
203
204 bool GetKey(COutPoint &key) const override;
205 bool GetValue(Coin &coin) const override;
206 unsigned int GetValueSize() const override;
207
208 bool Valid() const override;
209 void Next() override;
210
211private:
212 std::unique_ptr<CDBIterator> pcursor;
213 std::pair<char, COutPoint> keyTmp;
214
215 friend class CCoinsViewDB;
216};
217
218std::unique_ptr<CCoinsViewCursor> CCoinsViewDB::Cursor() const
219{
220 auto i = std::make_unique<CCoinsViewDBCursor>(
221 const_cast<CDBWrapper&>(*m_db).NewIterator(), GetBestBlock());
222 /* It seems that there are no "const iterators" for LevelDB. Since we
223 only need read operations on it, use a const-cast to get around
224 that restriction. */
225 i->pcursor->Seek(DB_COIN);
226 // Cache key of first record
227 if (i->pcursor->Valid()) {
228 CoinEntry entry(&i->keyTmp.second);
229 i->pcursor->GetKey(entry);
230 i->keyTmp.first = entry.key;
231 } else {
232 i->keyTmp.first = 0; // Make sure Valid() and GetKey() return false
233 }
234 return i;
235}
236
238{
239 // Return cached key
240 if (keyTmp.first == DB_COIN) {
241 key = keyTmp.second;
242 return true;
243 }
244 return false;
245}
246
248{
249 return pcursor->GetValue(coin);
250}
251
253{
254 return pcursor->GetValueSize();
255}
256
258{
259 return keyTmp.first == DB_COIN;
260}
261
263{
264 pcursor->Next();
265 CoinEntry entry(&keyTmp.second);
266 if (!pcursor->Valid() || !pcursor->GetKey(entry)) {
267 keyTmp.first = 0; // Invalidate cached key after last record so that Valid() and GetKey() return false
268 } else {
269 keyTmp.first = entry.key;
270 }
271}
272
273bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) {
274 CDBBatch batch(*this);
275 for (std::vector<std::pair<int, const CBlockFileInfo*> >::const_iterator it=fileInfo.begin(); it != fileInfo.end(); it++) {
276 batch.Write(std::make_pair(DB_BLOCK_FILES, it->first), *it->second);
277 }
278 batch.Write(DB_LAST_BLOCK, nLastFile);
279 for (std::vector<const CBlockIndex*>::const_iterator it=blockinfo.begin(); it != blockinfo.end(); it++) {
280 batch.Write(std::make_pair(DB_BLOCK_INDEX, (*it)->GetBlockHash()), CDiskBlockIndex(*it));
281 }
282 return WriteBatch(batch, true);
283}
284
285bool CBlockTreeDB::WriteFlag(const std::string &name, bool fValue) {
286 return Write(std::make_pair(DB_FLAG, name), fValue ? uint8_t{'1'} : uint8_t{'0'});
287}
288
289bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
290 uint8_t ch;
291 if (!Read(std::make_pair(DB_FLAG, name), ch))
292 return false;
293 fValue = ch == uint8_t{'1'};
294 return true;
295}
296
297bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
298{
299 std::unique_ptr<CDBIterator> pcursor(NewIterator());
300
301 pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256()));
302
303 // Load m_block_index
304 while (pcursor->Valid()) {
305 if (ShutdownRequested()) return false;
306 std::pair<uint8_t, uint256> key;
307 if (pcursor->GetKey(key) && key.first == DB_BLOCK_INDEX) {
308 CDiskBlockIndex diskindex;
309 if (pcursor->GetValue(diskindex)) {
310 // Construct block index object
311 CBlockIndex* pindexNew = insertBlockIndex(diskindex.GetBlockHash());
312 pindexNew->pprev = insertBlockIndex(diskindex.hashPrev);
313 pindexNew->nHeight = diskindex.nHeight;
314 pindexNew->nFile = diskindex.nFile;
315 pindexNew->nDataPos = diskindex.nDataPos;
316 pindexNew->nUndoPos = diskindex.nUndoPos;
317 pindexNew->nVersion = diskindex.nVersion;
318 pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
319 pindexNew->nTime = diskindex.nTime;
320 pindexNew->nBits = diskindex.nBits;
321 pindexNew->nNonce = diskindex.nNonce;
322 pindexNew->nStatus = diskindex.nStatus;
323 pindexNew->nTx = diskindex.nTx;
324
325 if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, consensusParams))
326 return error("%s: CheckProofOfWork failed: %s", __func__, pindexNew->ToString());
327
328 pcursor->Next();
329 } else {
330 return error("%s: failed to read value", __func__);
331 }
332 } else {
333 break;
334 }
335 }
336
337 return true;
338}
339
340namespace {
341
343class CCoins
344{
345public:
347 bool fCoinBase;
348
350 std::vector<CTxOut> vout;
351
353 int nHeight;
354
356 CCoins() : fCoinBase(false), vout(0), nHeight(0) { }
357
358 template<typename Stream>
359 void Unserialize(Stream &s) {
360 unsigned int nCode = 0;
361 // version
362 unsigned int nVersionDummy;
363 ::Unserialize(s, VARINT(nVersionDummy));
364 // header code
365 ::Unserialize(s, VARINT(nCode));
366 fCoinBase = nCode & 1;
367 std::vector<bool> vAvail(2, false);
368 vAvail[0] = (nCode & 2) != 0;
369 vAvail[1] = (nCode & 4) != 0;
370 unsigned int nMaskCode = (nCode / 8) + ((nCode & 6) != 0 ? 0 : 1);
371 // spentness bitmask
372 while (nMaskCode > 0) {
373 unsigned char chAvail = 0;
374 ::Unserialize(s, chAvail);
375 for (unsigned int p = 0; p < 8; p++) {
376 bool f = (chAvail & (1 << p)) != 0;
377 vAvail.push_back(f);
378 }
379 if (chAvail != 0)
380 nMaskCode--;
381 }
382 // txouts themself
383 vout.assign(vAvail.size(), CTxOut());
384 for (unsigned int i = 0; i < vAvail.size(); i++) {
385 if (vAvail[i])
386 ::Unserialize(s, Using<TxOutCompression>(vout[i]));
387 }
388 // coinbase height
390 }
391};
392
393}
394
400 std::unique_ptr<CDBIterator> pcursor(m_db->NewIterator());
401 pcursor->Seek(std::make_pair(DB_COINS, uint256()));
402 if (!pcursor->Valid()) {
403 return true;
404 }
405
406 int64_t count = 0;
407 LogPrintf("Upgrading utxo-set database...\n");
408 LogPrintf("[0%%]..."); /* Continued */
409 uiInterface.ShowProgress(_("Upgrading UTXO database").translated, 0, true);
410 size_t batch_size = 1 << 24;
411 CDBBatch batch(*m_db);
412 int reportDone = 0;
413 std::pair<unsigned char, uint256> key;
414 std::pair<unsigned char, uint256> prev_key = {DB_COINS, uint256()};
415 while (pcursor->Valid()) {
416 if (ShutdownRequested()) {
417 break;
418 }
419 if (pcursor->GetKey(key) && key.first == DB_COINS) {
420 if (count++ % 256 == 0) {
421 uint32_t high = 0x100 * *key.second.begin() + *(key.second.begin() + 1);
422 int percentageDone = (int)(high * 100.0 / 65536.0 + 0.5);
423 uiInterface.ShowProgress(_("Upgrading UTXO database").translated, percentageDone, true);
424 if (reportDone < percentageDone/10) {
425 // report max. every 10% step
426 LogPrintf("[%d%%]...", percentageDone); /* Continued */
427 reportDone = percentageDone/10;
428 }
429 }
430 CCoins old_coins;
431 if (!pcursor->GetValue(old_coins)) {
432 return error("%s: cannot parse CCoins record", __func__);
433 }
434 COutPoint outpoint(key.second, 0);
435 for (size_t i = 0; i < old_coins.vout.size(); ++i) {
436 if (!old_coins.vout[i].IsNull() && !old_coins.vout[i].scriptPubKey.IsUnspendable()) {
437 Coin newcoin(std::move(old_coins.vout[i]), old_coins.nHeight, old_coins.fCoinBase);
438 outpoint.n = i;
439 CoinEntry entry(&outpoint);
440 batch.Write(entry, newcoin);
441 }
442 }
443 batch.Erase(key);
444 if (batch.SizeEstimate() > batch_size) {
445 m_db->WriteBatch(batch);
446 batch.Clear();
447 m_db->CompactRange(prev_key, key);
448 prev_key = key;
449 }
450 pcursor->Next();
451 } else {
452 break;
453 }
454 }
455 m_db->WriteBatch(batch);
456 m_db->CompactRange({DB_COINS, uint256()}, key);
457 uiInterface.ShowProgress("", 100, false);
458 LogPrintf("[%s].\n", ShutdownRequested() ? "CANCELLED" : "DONE");
459 return !ShutdownRequested();
460}
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Definition: system.cpp:596
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:146
uint256 hashMerkleRoot
Definition: chain.h:199
std::string ToString() const
Definition: chain.h:294
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: chain.h:152
int nFile
Which # file this block is stored in (blk?????.dat)
Definition: chain.h:161
uint32_t nTime
Definition: chain.h:200
uint32_t nNonce
Definition: chain.h:202
unsigned int nUndoPos
Byte offset within rev?????.dat where this block's undo data is stored.
Definition: chain.h:167
uint256 GetBlockHash() const
Definition: chain.h:254
uint32_t nBits
Definition: chain.h:201
unsigned int nTx
Number of transactions in this block.
Definition: chain.h:177
int32_t nVersion
block header
Definition: chain.h:198
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:158
uint32_t nStatus
Verification status of this block.
Definition: chain.h:195
unsigned int nDataPos
Byte offset within blk?????.dat where this block's data is stored.
Definition: chain.h:164
Access to the block database (blocks/index/)
Definition: txdb.h:78
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &info)
Definition: txdb.cpp:175
CBlockTreeDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: txdb.cpp:172
bool WriteReindexing(bool fReindexing)
Definition: txdb.cpp:179
void ReadReindexing(bool &fReindexing)
Definition: txdb.cpp:186
bool WriteBatchSync(const std::vector< std::pair< int, const CBlockFileInfo * > > &fileInfo, int nLastFile, const std::vector< const CBlockIndex * > &blockinfo)
Definition: txdb.cpp:273
bool ReadFlag(const std::string &name, bool &fValue)
Definition: txdb.cpp:289
bool LoadBlockIndexGuts(const Consensus::Params &consensusParams, std::function< CBlockIndex *(const uint256 &)> insertBlockIndex)
Definition: txdb.cpp:297
bool ReadLastBlockFile(int &nFile)
Definition: txdb.cpp:190
bool WriteFlag(const std::string &name, bool fValue)
Definition: txdb.cpp:285
Cursor for iterating over CoinsView state.
Definition: coins.h:138
Specialization of CCoinsViewCursor to iterate over a CCoinsViewDB.
Definition: txdb.cpp:196
std::unique_ptr< CDBIterator > pcursor
Definition: txdb.cpp:212
bool GetKey(COutPoint &key) const override
Definition: txdb.cpp:237
bool GetValue(Coin &coin) const override
Definition: txdb.cpp:247
CCoinsViewDBCursor(CDBIterator *pcursorIn, const uint256 &hashBlockIn)
Definition: txdb.cpp:200
bool Valid() const override
Definition: txdb.cpp:257
unsigned int GetValueSize() const override
Definition: txdb.cpp:252
void Next() override
Definition: txdb.cpp:262
std::pair< char, COutPoint > keyTmp
Definition: txdb.cpp:213
CCoinsView backed by the coin database (chainstate/)
Definition: txdb.h:50
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: txdb.cpp:83
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: txdb.cpp:87
bool m_is_memory
Definition: txdb.h:54
std::unique_ptr< CDBWrapper > m_db
Definition: txdb.h:52
bool Upgrade()
Attempt to update from an older database format. Returns whether an error occurred.
Definition: txdb.cpp:399
CCoinsViewDB(fs::path ldb_path, size_t nCacheSize, bool fMemory, bool fWipe)
Definition: txdb.cpp:65
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: txdb.cpp:91
fs::path m_ldb_path
Definition: txdb.h:53
std::unique_ptr< CCoinsViewCursor > Cursor() const override
Get a cursor to iterate over the whole state.
Definition: txdb.cpp:218
void ResizeCache(size_t new_cache_size) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Dynamically alter the underlying leveldb cache size.
Definition: txdb.cpp:70
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) override
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: txdb.cpp:106
std::vector< uint256 > GetHeadBlocks() const override
Retrieve the range of blocks that may have been only partially written.
Definition: txdb.cpp:98
size_t EstimateSize() const override
Estimate database size (0 if not implemented)
Definition: txdb.cpp:167
Batch of changes queued to be written to a CDBWrapper.
Definition: dbwrapper.h:48
void Erase(const K &key)
Definition: dbwrapper.h:98
size_t SizeEstimate() const
Definition: dbwrapper.h:114
void Write(const K &key, const V &value)
Definition: dbwrapper.h:73
void Clear()
Definition: dbwrapper.h:66
bool WriteBatch(CDBBatch &batch, bool fSync=false)
Definition: dbwrapper.cpp:183
bool Read(const K &key, V &value) const
Definition: dbwrapper.h:231
CDBIterator * NewIterator()
Definition: dbwrapper.h:296
bool Erase(const K &key, bool fSync=false)
Definition: dbwrapper.h:284
bool Write(const K &key, const V &value, bool fSync=false)
Definition: dbwrapper.h:257
bool Exists(const K &key) const
Definition: dbwrapper.h:265
Used to marshal pointers into hashes for db storage.
Definition: chain.h:352
uint256 hashPrev
Definition: chain.h:354
uint256 GetBlockHash() const
Definition: chain.h:385
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:27
uint32_t n
Definition: transaction.h:30
An output of a transaction.
Definition: transaction.h:129
A UTXO entry.
Definition: coins.h:31
Fast randomness source.
Definition: random.h:120
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
Definition: random.h:190
unsigned char * begin()
Definition: uint256.h:58
bool IsNull() const
Definition: uint256.h:31
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
Definition: fs.h:34
256-bit opaque blob.
Definition: uint256.h:124
std::unordered_map< COutPoint, CCoinsCacheEntry, SaltedOutpointHasher > CCoinsMap
Definition: coins.h:134
#define LogPrint(category,...)
Definition: logging.h:191
#define LogPrintf(...)
Definition: logging.h:187
unsigned int nHeight
@ COINDB
Definition: logging.h:56
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params &params)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
Definition: pow.cpp:74
const char * name
Definition: rest.cpp:43
#define VARINT(obj)
Definition: serialize.h:443
#define VARINT_MODE(obj, mode)
Definition: serialize.h:442
@ NONNEGATIVE_SIGNED
#define SERIALIZE_METHODS(cls, obj)
Implement the Serialize and Unserialize methods by delegating to a single templated static method tha...
Definition: serialize.h:183
void Unserialize(Stream &s, char &a)
Definition: serialize.h:215
#define READWRITE(...)
Definition: serialize.h:147
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
Definition: shutdown.cpp:87
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition: block.h:115
@ DIRTY
DIRTY means the CCoinsCacheEntry is potentially different from the version in the parent cache.
Definition: coins.h:116
Parameters that influence chain consensus.
Definition: params.h:70
std::string translated
Definition: translation.h:18
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
static int count
Definition: tests.c:41
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:63
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:46
static constexpr uint8_t DB_TXINDEX_BLOCK
Definition: txdb.cpp:32
static constexpr uint8_t DB_LAST_BLOCK
Definition: txdb.cpp:29
std::optional< bilingual_str > CheckLegacyTxindex(CBlockTreeDB &block_tree_db)
Definition: txdb.cpp:35
static constexpr uint8_t DB_HEAD_BLOCKS
Definition: txdb.cpp:26
static constexpr uint8_t DB_REINDEX_FLAG
Definition: txdb.cpp:28
static constexpr uint8_t DB_BEST_BLOCK
Definition: txdb.cpp:25
static constexpr uint8_t DB_COIN
Definition: txdb.cpp:20
static constexpr uint8_t DB_FLAG
Definition: txdb.cpp:27
static constexpr uint8_t DB_COINS
Definition: txdb.cpp:21
static constexpr uint8_t DB_BLOCK_FILES
Definition: txdb.cpp:22
static constexpr uint8_t DB_BLOCK_INDEX
Definition: txdb.cpp:23
static const int64_t nDefaultDbBatchSize
-dbbatchsize default (bytes)
Definition: txdb.h:29
CClientUIInterface uiInterface
ArgsManager gArgs
Definition: system.cpp:85
assert(!tx.IsCoinBase())
std::vector< typename std::common_type< Args... >::type > Vector(Args &&... args)
Construct a vector with the specified elements.
Definition: vector.h:20