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