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