Bitcoin ABC  0.26.3
P2P Digital Currency
chain.cpp
Go to the documentation of this file.
1 // Copyright (c) 2018-2019 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 <interfaces/chain.h>
6 
7 #include <chain.h>
8 #include <chainparams.h>
9 #include <interfaces/handler.h>
10 #include <interfaces/wallet.h>
11 #include <net.h>
12 #include <net_processing.h>
13 #include <node/blockstorage.h>
14 #include <node/coin.h>
15 #include <node/context.h>
16 #include <node/transaction.h>
17 #include <node/ui_interface.h>
18 #include <policy/mempool.h>
19 #include <policy/policy.h>
20 #include <policy/settings.h>
21 #include <primitives/block.h>
22 #include <primitives/blockhash.h>
23 #include <rpc/protocol.h>
24 #include <rpc/server.h>
25 #include <shutdown.h>
26 #include <sync.h>
27 #include <timedata.h>
28 #include <txmempool.h>
29 #include <univalue.h>
30 #include <util/system.h>
31 #include <validation.h>
32 #include <validationinterface.h>
33 
34 #include <utility>
35 
36 namespace interfaces {
37 namespace {
38 
39  bool FillBlock(const CBlockIndex *index, const FoundBlock &block,
40  UniqueLock<RecursiveMutex> &lock, const CChain &active) {
41  if (!index) {
42  return false;
43  }
44  if (block.m_hash) {
45  *block.m_hash = index->GetBlockHash();
46  }
47  if (block.m_height) {
48  *block.m_height = index->nHeight;
49  }
50  if (block.m_time) {
51  *block.m_time = index->GetBlockTime();
52  }
53  if (block.m_max_time) {
54  *block.m_max_time = index->GetBlockTimeMax();
55  }
56  if (block.m_mtp_time) {
57  *block.m_mtp_time = index->GetMedianTimePast();
58  }
59  if (block.m_in_active_chain) {
60  *block.m_in_active_chain = active[index->nHeight] == index;
61  }
62  if (block.m_next_block) {
63  FillBlock(active[index->nHeight] == index
64  ? active[index->nHeight + 1]
65  : nullptr,
66  *block.m_next_block, lock, active);
67  }
68  if (block.m_data) {
69  REVERSE_LOCK(lock);
70  if (!ReadBlockFromDisk(*block.m_data, index,
71  Params().GetConsensus())) {
72  block.m_data->SetNull();
73  }
74  }
75  return true;
76  }
77 
78  class NotificationsProxy : public CValidationInterface {
79  public:
80  explicit NotificationsProxy(
81  std::shared_ptr<Chain::Notifications> notifications)
82  : m_notifications(std::move(notifications)) {}
83  virtual ~NotificationsProxy() = default;
84  void TransactionAddedToMempool(const CTransactionRef &tx,
85  uint64_t mempool_sequence) override {
86  m_notifications->transactionAddedToMempool(tx, mempool_sequence);
87  }
88  void TransactionRemovedFromMempool(const CTransactionRef &tx,
89  MemPoolRemovalReason reason,
90  uint64_t mempool_sequence) override {
91  m_notifications->transactionRemovedFromMempool(tx, reason,
92  mempool_sequence);
93  }
94  void BlockConnected(const std::shared_ptr<const CBlock> &block,
95  const CBlockIndex *index) override {
96  m_notifications->blockConnected(*block, index->nHeight);
97  }
98  void BlockDisconnected(const std::shared_ptr<const CBlock> &block,
99  const CBlockIndex *index) override {
100  m_notifications->blockDisconnected(*block, index->nHeight);
101  }
102  void UpdatedBlockTip(const CBlockIndex *index,
103  const CBlockIndex *fork_index,
104  bool is_ibd) override {
105  m_notifications->updatedBlockTip();
106  }
107  void ChainStateFlushed(const CBlockLocator &locator) override {
108  m_notifications->chainStateFlushed(locator);
109  }
110  std::shared_ptr<Chain::Notifications> m_notifications;
111  };
112 
113  class NotificationsHandlerImpl : public Handler {
114  public:
115  explicit NotificationsHandlerImpl(
116  std::shared_ptr<Chain::Notifications> notifications)
117  : m_proxy(std::make_shared<NotificationsProxy>(
118  std::move(notifications))) {
120  }
121  ~NotificationsHandlerImpl() override { disconnect(); }
122  void disconnect() override {
123  if (m_proxy) {
125  m_proxy.reset();
126  }
127  }
128  std::shared_ptr<NotificationsProxy> m_proxy;
129  };
130 
131  class RpcHandlerImpl : public Handler {
132  public:
133  explicit RpcHandlerImpl(const CRPCCommand &command)
134  : m_command(command), m_wrapped_command(&command) {
135  m_command.actor = [this](const Config &config,
136  const JSONRPCRequest &request,
137  UniValue &result, bool last_handler) {
138  if (!m_wrapped_command) {
139  return false;
140  }
141  try {
142  return m_wrapped_command->actor(config, request, result,
143  last_handler);
144  } catch (const UniValue &e) {
145  // If this is not the last handler and a wallet not found
146  // exception was thrown, return false so the next handler
147  // can try to handle the request. Otherwise, reraise the
148  // exception.
149  if (!last_handler) {
150  const UniValue &code = e["code"];
151  if (code.isNum() &&
152  code.get_int() == RPC_WALLET_NOT_FOUND) {
153  return false;
154  }
155  }
156  throw;
157  }
158  };
160  }
161 
162  void disconnect() final {
163  if (m_wrapped_command) {
164  m_wrapped_command = nullptr;
166  }
167  }
168 
169  ~RpcHandlerImpl() override { disconnect(); }
170 
173  };
174 
175  class ChainImpl : public Chain {
176  private:
177  ChainstateManager &chainman() { return *Assert(m_node.chainman); }
178 
179  public:
180  explicit ChainImpl(NodeContext &node, const CChainParams &params)
181  : m_node(node), m_params(params) {}
182  std::optional<int> getHeight() override {
183  LOCK(::cs_main);
184  const CChain &active = Assert(m_node.chainman)->ActiveChain();
185  int height = active.Height();
186  if (height >= 0) {
187  return height;
188  }
189  return std::nullopt;
190  }
191  BlockHash getBlockHash(int height) override {
192  LOCK(::cs_main);
193  const CChain &active = Assert(m_node.chainman)->ActiveChain();
194  CBlockIndex *block = active[height];
195  assert(block);
196  return block->GetBlockHash();
197  }
198  bool haveBlockOnDisk(int height) override {
199  LOCK(cs_main);
200  const CChain &active = Assert(m_node.chainman)->ActiveChain();
201  CBlockIndex *block = active[height];
202  return block && (block->nStatus.hasData() != 0) && block->nTx > 0;
203  }
204  CBlockLocator getTipLocator() override {
205  LOCK(cs_main);
206  const CChain &active = Assert(m_node.chainman)->ActiveChain();
207  return active.GetLocator();
208  }
209  bool contextualCheckTransactionForCurrentBlock(
210  const CTransaction &tx, TxValidationState &state) override {
211  LOCK(cs_main);
212  const CChain &active = Assert(m_node.chainman)->ActiveChain();
214  active.Tip(), m_params.GetConsensus(), tx, state);
215  }
216  std::optional<int>
217  findLocatorFork(const CBlockLocator &locator) override {
218  LOCK(cs_main);
219  const CChain &active = Assert(m_node.chainman)->ActiveChain();
220  if (CBlockIndex *fork =
221  m_node.chainman->m_blockman.FindForkInGlobalIndex(
222  active, locator)) {
223  return fork->nHeight;
224  }
225  return std::nullopt;
226  }
227  bool findBlock(const BlockHash &hash,
228  const FoundBlock &block) override {
229  WAIT_LOCK(cs_main, lock);
230  const CChain &active = Assert(m_node.chainman)->ActiveChain();
231  return FillBlock(m_node.chainman->m_blockman.LookupBlockIndex(hash),
232  block, lock, active);
233  }
234  bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height,
235  const FoundBlock &block) override {
236  WAIT_LOCK(cs_main, lock);
237  const CChain &active = Assert(m_node.chainman)->ActiveChain();
238  return FillBlock(active.FindEarliestAtLeast(min_time, min_height),
239  block, lock, active);
240  }
241  bool findAncestorByHeight(const BlockHash &block_hash,
242  int ancestor_height,
243  const FoundBlock &ancestor_out) override {
244  WAIT_LOCK(cs_main, lock);
245  const CChain &active = Assert(m_node.chainman)->ActiveChain();
246  if (const CBlockIndex *block =
247  m_node.chainman->m_blockman.LookupBlockIndex(block_hash)) {
248  if (const CBlockIndex *ancestor =
249  block->GetAncestor(ancestor_height)) {
250  return FillBlock(ancestor, ancestor_out, lock, active);
251  }
252  }
253  return FillBlock(nullptr, ancestor_out, lock, active);
254  }
255  bool findAncestorByHash(const BlockHash &block_hash,
256  const BlockHash &ancestor_hash,
257  const FoundBlock &ancestor_out) override {
258  WAIT_LOCK(cs_main, lock);
259  const CChain &active = Assert(m_node.chainman)->ActiveChain();
260  const CBlockIndex *block =
261  m_node.chainman->m_blockman.LookupBlockIndex(block_hash);
262  const CBlockIndex *ancestor =
263  m_node.chainman->m_blockman.LookupBlockIndex(ancestor_hash);
264  if (block && ancestor &&
265  block->GetAncestor(ancestor->nHeight) != ancestor) {
266  ancestor = nullptr;
267  }
268  return FillBlock(ancestor, ancestor_out, lock, active);
269  }
270  bool findCommonAncestor(const BlockHash &block_hash1,
271  const BlockHash &block_hash2,
272  const FoundBlock &ancestor_out,
273  const FoundBlock &block1_out,
274  const FoundBlock &block2_out) override {
275  WAIT_LOCK(cs_main, lock);
276  const CChain &active = Assert(m_node.chainman)->ActiveChain();
277  const CBlockIndex *block1 =
278  m_node.chainman->m_blockman.LookupBlockIndex(block_hash1);
279  const CBlockIndex *block2 =
280  m_node.chainman->m_blockman.LookupBlockIndex(block_hash2);
281  const CBlockIndex *ancestor =
282  block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
283  // Using & instead of && below to avoid short circuiting and leaving
284  // output uninitialized. Cast bool to int to avoid
285  // -Wbitwise-instead-of-logical compiler warnings.
286  return int{FillBlock(ancestor, ancestor_out, lock, active)} &
287  int{FillBlock(block1, block1_out, lock, active)} &
288  int{FillBlock(block2, block2_out, lock, active)};
289  }
290  void findCoins(std::map<COutPoint, Coin> &coins) override {
291  return FindCoins(m_node, coins);
292  }
293  double guessVerificationProgress(const BlockHash &block_hash) override {
294  LOCK(cs_main);
296  Params().TxData(),
297  chainman().m_blockman.LookupBlockIndex(block_hash));
298  }
299  bool hasBlocks(const BlockHash &block_hash, int min_height,
300  std::optional<int> max_height) override {
301  // hasBlocks returns true if all ancestors of block_hash in
302  // specified range have block data (are not pruned), false if any
303  // ancestors in specified range are missing data.
304  //
305  // For simplicity and robustness, min_height and max_height are only
306  // used to limit the range, and passing min_height that's too low or
307  // max_height that's too high will not crash or change the result.
308  LOCK(::cs_main);
309  if (CBlockIndex *block =
310  chainman().m_blockman.LookupBlockIndex(block_hash)) {
311  if (max_height && block->nHeight >= *max_height) {
312  block = block->GetAncestor(*max_height);
313  }
314  for (; block->nStatus.hasData(); block = block->pprev) {
315  // Check pprev to not segfault if min_height is too low
316  if (block->nHeight <= min_height || !block->pprev) {
317  return true;
318  }
319  }
320  }
321  return false;
322  }
323  bool hasDescendantsInMempool(const TxId &txid) override {
324  if (!m_node.mempool) {
325  return false;
326  }
327  LOCK(m_node.mempool->cs);
328  auto it = m_node.mempool->GetIter(txid);
329  return it && (*it)->GetCountWithDescendants() > 1;
330  }
331  bool broadcastTransaction(const Config &config,
332  const CTransactionRef &tx,
333  const Amount &max_tx_fee, bool relay,
334  std::string &err_string) override {
336  m_node, config, tx, err_string, max_tx_fee, relay,
337  /*wait_callback*/ false);
338  // Chain clients only care about failures to accept the tx to the
339  // mempool. Disregard non-mempool related failures. Note: this will
340  // need to be updated if BroadcastTransactions() is updated to
341  // return other non-mempool failures that Chain clients do not need
342  // to know about.
343  return err == TransactionError::OK;
344  }
345  void getTransactionAncestry(const TxId &txid, size_t &ancestors,
346  size_t &descendants) override {
347  ancestors = descendants = 0;
348  if (!m_node.mempool) {
349  return;
350  }
351  m_node.mempool->GetTransactionAncestry(txid, ancestors,
352  descendants);
353  }
354  void getPackageLimits(size_t &limit_ancestor_count,
355  size_t &limit_descendant_count) override {
356  limit_ancestor_count = size_t(
357  std::max<int64_t>(1, gArgs.GetIntArg("-limitancestorcount",
359  limit_descendant_count = size_t(std::max<int64_t>(
360  1, gArgs.GetIntArg("-limitdescendantcount",
362  }
363  bool checkChainLimits(const CTransactionRef &tx) override {
364  if (!m_node.mempool) {
365  return true;
366  }
367  LockPoints lp;
368  CTxMemPoolEntry entry(tx, Amount(), 0, 0, false, 0, lp);
369  CTxMemPool::setEntries ancestors;
370  auto limit_ancestor_count =
371  gArgs.GetIntArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
372  auto limit_ancestor_size =
373  gArgs.GetIntArg("-limitancestorsize",
375  1000;
376  auto limit_descendant_count = gArgs.GetIntArg(
377  "-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
378  auto limit_descendant_size =
379  gArgs.GetIntArg("-limitdescendantsize",
381  1000;
382  std::string unused_error_string;
383  LOCK(m_node.mempool->cs);
384  return m_node.mempool->CalculateMemPoolAncestors(
385  entry, ancestors, limit_ancestor_count, limit_ancestor_size,
386  limit_descendant_count, limit_descendant_size,
387  unused_error_string);
388  }
389  CFeeRate estimateFee() const override {
390  if (!m_node.mempool) {
391  return {};
392  }
393  return m_node.mempool->estimateFee();
394  }
395  CFeeRate relayMinFee() override { return ::minRelayTxFee; }
396  CFeeRate relayDustFee() override { return ::dustRelayFee; }
397  bool havePruned() override {
398  LOCK(cs_main);
400  }
401  bool isReadyToBroadcast() override {
402  return !::fImporting && !::fReindex && !isInitialBlockDownload();
403  }
404  bool isInitialBlockDownload() override {
405  return chainman().ActiveChainstate().IsInitialBlockDownload();
406  }
407  bool shutdownRequested() override { return ShutdownRequested(); }
408  int64_t getAdjustedTime() override { return GetAdjustedTime(); }
409  void initMessage(const std::string &message) override {
410  ::uiInterface.InitMessage(message);
411  }
412  void initWarning(const bilingual_str &message) override {
413  InitWarning(message);
414  }
415  void initError(const bilingual_str &message) override {
416  InitError(message);
417  }
418  void showProgress(const std::string &title, int progress,
419  bool resume_possible) override {
420  ::uiInterface.ShowProgress(title, progress, resume_possible);
421  }
422  std::unique_ptr<Handler> handleNotifications(
423  std::shared_ptr<Notifications> notifications) override {
424  return std::make_unique<NotificationsHandlerImpl>(
425  std::move(notifications));
426  }
427  void
428  waitForNotificationsIfTipChanged(const BlockHash &old_tip) override {
429  if (!old_tip.IsNull()) {
430  LOCK(::cs_main);
431  const CChain &active = Assert(m_node.chainman)->ActiveChain();
432  if (old_tip == active.Tip()->GetBlockHash()) {
433  return;
434  }
435  }
437  }
438 
439  std::unique_ptr<Handler>
440  handleRpc(const CRPCCommand &command) override {
441  return std::make_unique<RpcHandlerImpl>(command);
442  }
443  bool rpcEnableDeprecated(const std::string &method) override {
444  return IsDeprecatedRPCEnabled(gArgs, method);
445  }
446  void rpcRunLater(const std::string &name, std::function<void()> fn,
447  int64_t seconds) override {
448  RPCRunLater(name, std::move(fn), seconds);
449  }
450  int rpcSerializationFlags() override { return RPCSerializationFlags(); }
451  util::SettingsValue getRwSetting(const std::string &name) override {
452  util::SettingsValue result;
453  gArgs.LockSettings([&](const util::Settings &settings) {
454  if (const util::SettingsValue *value =
455  util::FindKey(settings.rw_settings, name)) {
456  result = *value;
457  }
458  });
459  return result;
460  }
461  bool updateRwSetting(const std::string &name,
462  const util::SettingsValue &value) override {
463  gArgs.LockSettings([&](util::Settings &settings) {
464  if (value.isNull()) {
465  settings.rw_settings.erase(name);
466  } else {
467  settings.rw_settings[name] = value;
468  }
469  });
470  return gArgs.WriteSettingsFile();
471  }
472  void requestMempoolTransactions(Notifications &notifications) override {
473  if (!m_node.mempool) {
474  return;
475  }
476  LOCK2(::cs_main, m_node.mempool->cs);
477  for (const CTxMemPoolEntry &entry : m_node.mempool->mapTx) {
478  notifications.transactionAddedToMempool(
479  entry.GetSharedTx(), 0 /* mempool_sequence */);
480  }
481  }
482  const CChainParams &params() const override { return m_params; }
485  };
486 
487 } // namespace
488 
489 std::unique_ptr<Chain> MakeChain(NodeContext &node,
490  const CChainParams &params) {
491  return std::make_unique<ChainImpl>(node, params);
492 }
493 
494 } // namespace interfaces
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &params)
Functions for disk access for blocks.
bool fHavePruned
Pruning-related variables and constants.
std::atomic_bool fReindex
std::atomic_bool fImporting
const CBlockIndex * LastCommonAncestor(const CBlockIndex *pa, const CBlockIndex *pb)
Find the last common ancestor two blocks have.
Definition: chain.cpp:118
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:91
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Definition: check.h:56
bool WriteSettingsFile(std::vector< std::string > *errors=nullptr) const
Write settings file.
Definition: system.cpp:556
void LockSettings(Fn &&fn)
Access settings with lock held.
Definition: system.h:413
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:23
BlockStatus nStatus
Verification status of this block. See enum BlockStatus.
Definition: blockindex.h:85
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: blockindex.h:30
int64_t GetBlockTime() const
Definition: blockindex.h:169
int64_t GetMedianTimePast() const
Definition: blockindex.h:181
int64_t GetBlockTimeMax() const
Definition: blockindex.h:171
unsigned int nTx
Number of transactions in this block.
Definition: blockindex.h:58
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
Definition: blockindex.cpp:71
BlockHash GetBlockHash() const
Definition: blockindex.h:142
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: blockindex.h:36
An in-memory indexed chain of blocks.
Definition: chain.h:152
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:168
CBlockLocator GetLocator(const CBlockIndex *pindex=nullptr) const
Return a CBlockLocator that refers to a block in this chain (by default the tip).
Definition: chain.cpp:24
CBlockIndex * FindEarliestAtLeast(int64_t nTime, int height) const
Find the earliest block with timestamp equal or greater than the given time and height equal or great...
Definition: chain.cpp:68
int Height() const
Return the maximal height in the chain.
Definition: chain.h:204
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:74
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:86
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
std::string name
Definition: server.h:175
Actor actor
Definition: server.h:176
bool removeCommand(const std::string &name, const CRPCCommand *pcmd)
Definition: server.cpp:330
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:322
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:194
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition: txmempool.h:81
CTransactionRef GetSharedTx() const
Definition: txmempool.h:141
std::set< txiter, CompareIteratorById > setEntries
Definition: txmempool.h:587
Implement this to subscribe to events generated in validation.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:1145
Definition: config.h:17
bool isNull() const
Definition: univalue.h:89
bool isNum() const
Definition: univalue.h:94
int get_int() const
Wrapper around std::unique_lock style lock for Mutex.
Definition: sync.h:137
bool IsNull() const
Definition: uint256.h:30
void FindCoins(const NodeContext &node, std::map< COutPoint, Coin > &coins)
Look up unspent output information.
Definition: coin.cpp:11
TransactionError
Definition: error.h:22
NodeContext & m_node
Definition: chain.cpp:483
std::shared_ptr< Chain::Notifications > m_notifications
Definition: chain.cpp:110
CRPCCommand m_command
Definition: chain.cpp:171
const CChainParams & m_params
Definition: chain.cpp:484
const CRPCCommand * m_wrapped_command
Definition: chain.cpp:172
std::shared_ptr< NotificationsProxy > m_proxy
Definition: chain.cpp:128
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT
Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants.
Definition: mempool.h:27
static constexpr unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT
Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors.
Definition: mempool.h:20
static constexpr unsigned int DEFAULT_DESCENDANT_LIMIT
Default for -limitdescendantcount, max number of in-mempool descendants.
Definition: mempool.h:22
static constexpr unsigned int DEFAULT_ANCESTOR_LIMIT
Default for -limitancestorcount, max number of in-mempool ancestors.
Definition: mempool.h:15
LockPoints lp
std::unique_ptr< Chain > MakeChain(NodeContext &node, const CChainParams &params)
Return implementation of Chain interface.
Definition: chain.cpp:489
auto FindKey(Map &&map, Key &&key) -> decltype(&map.at(key))
Map lookup helper.
Definition: settings.h:110
TransactionError BroadcastTransaction(NodeContext &node, const Config &config, const CTransactionRef tx, std::string &err_string, const Amount max_tx_fee, bool relay, bool wait_callback)
Submit a transaction to the mempool and (optionally) relay it to all P2P peers.
Definition: transaction.cpp:33
CFeeRate dustRelayFee
Definition: settings.cpp:11
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:319
const char * name
Definition: rest.cpp:44
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
Definition: protocol.h:109
bool IsDeprecatedRPCEnabled(const ArgsManager &args, const std::string &method)
Definition: server.cpp:402
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
Definition: server.cpp:585
int RPCSerializationFlags()
Retrieves any serialization flags requested in command line argument.
Definition: server.cpp:600
CRPCTable tableRPC
Definition: server.cpp:604
bool ShutdownRequested()
Definition: shutdown.cpp:34
Definition: amount.h:19
A BlockHash is a unqiue identifier for a block.
Definition: blockhash.h:13
bool hasData() const
Definition: blockstatus.h:54
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
NodeContext struct containing references to chain state and connection state.
Definition: context.h:36
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:40
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:38
A TxId is the identifier of a transaction.
Definition: txid.h:14
Bilingual messages:
Definition: translation.h:17
Stored settings.
Definition: settings.h:31
std::map< std::string, SettingsValue > rw_settings
Map of setting name to read-write file setting value.
Definition: settings.h:37
#define WAIT_LOCK(cs, name)
Definition: sync.h:251
#define LOCK2(cs1, cs2)
Definition: sync.h:246
#define LOCK(cs)
Definition: sync.h:243
#define REVERSE_LOCK(g)
Definition: sync.h:235
ArgsManager gArgs
Definition: system.cpp:77
int64_t GetAdjustedTime()
Definition: timedata.cpp:34
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:402
CClientUIInterface uiInterface
void InitWarning(const bilingual_str &str)
Show warning message.
bool InitError(const bilingual_str &str)
Show error message.
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess how far we are in the verification process at the given block index require cs_main if pindex h...
bool ContextualCheckTransactionForCurrentBlock(const CBlockIndex *active_chain_tip, const Consensus::Params &params, const CTransaction &tx, TxValidationState &state, int flags)
This is a variant of ContextualCheckTransaction which computes the contextual check for a transaction...
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
Definition: validation.cpp:105
assert(!tx.IsCoinBase())
void UnregisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Unregister subscriber.
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
void RegisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Register subscriber.