Bitcoin Core  0.20.99
P2P Digital Currency
chain.cpp
Go to the documentation of this file.
1 // Copyright (c) 2018-2020 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/coin.h>
14 #include <node/context.h>
15 #include <node/transaction.h>
16 #include <node/ui_interface.h>
17 #include <policy/fees.h>
18 #include <policy/policy.h>
19 #include <policy/rbf.h>
20 #include <policy/settings.h>
21 #include <primitives/block.h>
22 #include <primitives/transaction.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 <uint256.h>
30 #include <univalue.h>
31 #include <util/system.h>
32 #include <validation.h>
33 #include <validationinterface.h>
34 
35 #include <memory>
36 #include <utility>
37 
38 namespace interfaces {
39 namespace {
40 
41 bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock)
42 {
43  if (!index) return false;
44  if (block.m_hash) *block.m_hash = index->GetBlockHash();
45  if (block.m_height) *block.m_height = index->nHeight;
46  if (block.m_time) *block.m_time = index->GetBlockTime();
47  if (block.m_max_time) *block.m_max_time = index->GetBlockTimeMax();
48  if (block.m_mtp_time) *block.m_mtp_time = index->GetMedianTimePast();
49  if (block.m_data) {
50  REVERSE_LOCK(lock);
51  if (!ReadBlockFromDisk(*block.m_data, index, Params().GetConsensus())) block.m_data->SetNull();
52  }
53  return true;
54 }
55 
56 class NotificationsProxy : public CValidationInterface
57 {
58 public:
59  explicit NotificationsProxy(std::shared_ptr<Chain::Notifications> notifications)
60  : m_notifications(std::move(notifications)) {}
61  virtual ~NotificationsProxy() = default;
62  void TransactionAddedToMempool(const CTransactionRef& tx) override
63  {
64  m_notifications->transactionAddedToMempool(tx);
65  }
66  void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) override
67  {
68  m_notifications->transactionRemovedFromMempool(tx, reason);
69  }
70  void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
71  {
72  m_notifications->blockConnected(*block, index->nHeight);
73  }
74  void BlockDisconnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
75  {
76  m_notifications->blockDisconnected(*block, index->nHeight);
77  }
78  void UpdatedBlockTip(const CBlockIndex* index, const CBlockIndex* fork_index, bool is_ibd) override
79  {
80  m_notifications->updatedBlockTip();
81  }
82  void ChainStateFlushed(const CBlockLocator& locator) override { m_notifications->chainStateFlushed(locator); }
83  std::shared_ptr<Chain::Notifications> m_notifications;
84 };
85 
86 class NotificationsHandlerImpl : public Handler
87 {
88 public:
89  explicit NotificationsHandlerImpl(std::shared_ptr<Chain::Notifications> notifications)
90  : m_proxy(std::make_shared<NotificationsProxy>(std::move(notifications)))
91  {
93  }
94  ~NotificationsHandlerImpl() override { disconnect(); }
95  void disconnect() override
96  {
97  if (m_proxy) {
99  m_proxy.reset();
100  }
101  }
102  std::shared_ptr<NotificationsProxy> m_proxy;
103 };
104 
105 class RpcHandlerImpl : public Handler
106 {
107 public:
108  explicit RpcHandlerImpl(const CRPCCommand& command) : m_command(command), m_wrapped_command(&command)
109  {
110  m_command.actor = [this](const JSONRPCRequest& request, UniValue& result, bool last_handler) {
111  if (!m_wrapped_command) return false;
112  try {
113  return m_wrapped_command->actor(request, result, last_handler);
114  } catch (const UniValue& e) {
115  // If this is not the last handler and a wallet not found
116  // exception was thrown, return false so the next handler can
117  // try to handle the request. Otherwise, reraise the exception.
118  if (!last_handler) {
119  const UniValue& code = e["code"];
120  if (code.isNum() && code.get_int() == RPC_WALLET_NOT_FOUND) {
121  return false;
122  }
123  }
124  throw;
125  }
126  };
128  }
129 
130  void disconnect() final
131  {
132  if (m_wrapped_command) {
133  m_wrapped_command = nullptr;
135  }
136  }
137 
138  ~RpcHandlerImpl() override { disconnect(); }
139 
142 };
143 
144 class ChainImpl : public Chain
145 {
146 public:
147  explicit ChainImpl(NodeContext& node) : m_node(node) {}
148  Optional<int> getHeight() override
149  {
150  LOCK(::cs_main);
151  int height = ::ChainActive().Height();
152  if (height >= 0) {
153  return height;
154  }
155  return nullopt;
156  }
157  Optional<int> getBlockHeight(const uint256& hash) override
158  {
159  LOCK(::cs_main);
160  CBlockIndex* block = LookupBlockIndex(hash);
161  if (block && ::ChainActive().Contains(block)) {
162  return block->nHeight;
163  }
164  return nullopt;
165  }
166  uint256 getBlockHash(int height) override
167  {
168  LOCK(::cs_main);
169  CBlockIndex* block = ::ChainActive()[height];
170  assert(block);
171  return block->GetBlockHash();
172  }
173  bool haveBlockOnDisk(int height) override
174  {
175  LOCK(cs_main);
176  CBlockIndex* block = ::ChainActive()[height];
177  return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0;
178  }
179  Optional<int> findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) override
180  {
181  LOCK(cs_main);
182  CBlockIndex* block = ::ChainActive().FindEarliestAtLeast(time, height);
183  if (block) {
184  if (hash) *hash = block->GetBlockHash();
185  return block->nHeight;
186  }
187  return nullopt;
188  }
189  CBlockLocator getTipLocator() override
190  {
191  LOCK(cs_main);
193  }
194  bool checkFinalTx(const CTransaction& tx) override
195  {
196  LOCK(cs_main);
197  return CheckFinalTx(tx);
198  }
199  Optional<int> findLocatorFork(const CBlockLocator& locator) override
200  {
201  LOCK(cs_main);
202  if (CBlockIndex* fork = FindForkInGlobalIndex(::ChainActive(), locator)) {
203  return fork->nHeight;
204  }
205  return nullopt;
206  }
207  bool findBlock(const uint256& hash, const FoundBlock& block) override
208  {
209  WAIT_LOCK(cs_main, lock);
210  return FillBlock(LookupBlockIndex(hash), block, lock);
211  }
212  bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock& block) override
213  {
214  WAIT_LOCK(cs_main, lock);
215  return FillBlock(ChainActive().FindEarliestAtLeast(min_time, min_height), block, lock);
216  }
217  bool findNextBlock(const uint256& block_hash, int block_height, const FoundBlock& next, bool* reorg) override {
218  WAIT_LOCK(cs_main, lock);
219  CBlockIndex* block = ChainActive()[block_height];
220  if (block && block->GetBlockHash() != block_hash) block = nullptr;
221  if (reorg) *reorg = !block;
222  return FillBlock(block ? ChainActive()[block_height + 1] : nullptr, next, lock);
223  }
224  bool findAncestorByHeight(const uint256& block_hash, int ancestor_height, const FoundBlock& ancestor_out) override
225  {
226  WAIT_LOCK(cs_main, lock);
227  if (const CBlockIndex* block = LookupBlockIndex(block_hash)) {
228  if (const CBlockIndex* ancestor = block->GetAncestor(ancestor_height)) {
229  return FillBlock(ancestor, ancestor_out, lock);
230  }
231  }
232  return FillBlock(nullptr, ancestor_out, lock);
233  }
234  bool findAncestorByHash(const uint256& block_hash, const uint256& ancestor_hash, const FoundBlock& ancestor_out) override
235  {
236  WAIT_LOCK(cs_main, lock);
237  const CBlockIndex* block = LookupBlockIndex(block_hash);
238  const CBlockIndex* ancestor = LookupBlockIndex(ancestor_hash);
239  if (block && ancestor && block->GetAncestor(ancestor->nHeight) != ancestor) ancestor = nullptr;
240  return FillBlock(ancestor, ancestor_out, lock);
241  }
242  bool findCommonAncestor(const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
243  {
244  WAIT_LOCK(cs_main, lock);
245  const CBlockIndex* block1 = LookupBlockIndex(block_hash1);
246  const CBlockIndex* block2 = LookupBlockIndex(block_hash2);
247  const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
248  // Using & instead of && below to avoid short circuiting and leaving
249  // output uninitialized.
250  return FillBlock(ancestor, ancestor_out, lock) & FillBlock(block1, block1_out, lock) & FillBlock(block2, block2_out, lock);
251  }
252  void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); }
253  double guessVerificationProgress(const uint256& block_hash) override
254  {
255  LOCK(cs_main);
256  return GuessVerificationProgress(Params().TxData(), LookupBlockIndex(block_hash));
257  }
258  bool hasBlocks(const uint256& block_hash, int min_height, Optional<int> max_height) override
259  {
260  // hasBlocks returns true if all ancestors of block_hash in specified
261  // range have block data (are not pruned), false if any ancestors in
262  // specified range are missing data.
263  //
264  // For simplicity and robustness, min_height and max_height are only
265  // used to limit the range, and passing min_height that's too low or
266  // max_height that's too high will not crash or change the result.
267  LOCK(::cs_main);
268  if (CBlockIndex* block = LookupBlockIndex(block_hash)) {
269  if (max_height && block->nHeight >= *max_height) block = block->GetAncestor(*max_height);
270  for (; block->nStatus & BLOCK_HAVE_DATA; block = block->pprev) {
271  // Check pprev to not segfault if min_height is too low
272  if (block->nHeight <= min_height || !block->pprev) return true;
273  }
274  }
275  return false;
276  }
277  RBFTransactionState isRBFOptIn(const CTransaction& tx) override
278  {
279  LOCK(::mempool.cs);
280  return IsRBFOptIn(tx, ::mempool);
281  }
282  bool hasDescendantsInMempool(const uint256& txid) override
283  {
284  LOCK(::mempool.cs);
285  auto it = ::mempool.GetIter(txid);
286  return it && (*it)->GetCountWithDescendants() > 1;
287  }
288  bool broadcastTransaction(const CTransactionRef& tx,
289  const CAmount& max_tx_fee,
290  bool relay,
291  std::string& err_string) override
292  {
293  const TransactionError err = BroadcastTransaction(m_node, tx, err_string, max_tx_fee, relay, /*wait_callback*/ false);
294  // Chain clients only care about failures to accept the tx to the mempool. Disregard non-mempool related failures.
295  // Note: this will need to be updated if BroadcastTransactions() is updated to return other non-mempool failures
296  // that Chain clients do not need to know about.
297  return TransactionError::OK == err;
298  }
299  void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) override
300  {
301  ::mempool.GetTransactionAncestry(txid, ancestors, descendants);
302  }
303  void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override
304  {
305  limit_ancestor_count = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
306  limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
307  }
308  bool checkChainLimits(const CTransactionRef& tx) override
309  {
310  LockPoints lp;
311  CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp);
312  CTxMemPool::setEntries ancestors;
313  auto limit_ancestor_count = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
314  auto limit_ancestor_size = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * 1000;
315  auto limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
316  auto limit_descendant_size = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000;
317  std::string unused_error_string;
318  LOCK(::mempool.cs);
319  return ::mempool.CalculateMemPoolAncestors(entry, ancestors, limit_ancestor_count, limit_ancestor_size,
320  limit_descendant_count, limit_descendant_size, unused_error_string);
321  }
322  CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation* calc) override
323  {
324  return ::feeEstimator.estimateSmartFee(num_blocks, calc, conservative);
325  }
326  unsigned int estimateMaxBlocks() override
327  {
329  }
330  CFeeRate mempoolMinFee() override
331  {
333  }
334  CFeeRate relayMinFee() override { return ::minRelayTxFee; }
335  CFeeRate relayIncrementalFee() override { return ::incrementalRelayFee; }
336  CFeeRate relayDustFee() override { return ::dustRelayFee; }
337  bool havePruned() override
338  {
339  LOCK(cs_main);
341  }
342  bool isReadyToBroadcast() override { return !::fImporting && !::fReindex && !isInitialBlockDownload(); }
343  bool isInitialBlockDownload() override { return ::ChainstateActive().IsInitialBlockDownload(); }
344  bool shutdownRequested() override { return ShutdownRequested(); }
345  int64_t getAdjustedTime() override { return GetAdjustedTime(); }
346  void initMessage(const std::string& message) override { ::uiInterface.InitMessage(message); }
347  void initWarning(const bilingual_str& message) override { InitWarning(message); }
348  void initError(const bilingual_str& message) override { InitError(message); }
349  void showProgress(const std::string& title, int progress, bool resume_possible) override
350  {
351  ::uiInterface.ShowProgress(title, progress, resume_possible);
352  }
353  std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) override
354  {
355  return MakeUnique<NotificationsHandlerImpl>(std::move(notifications));
356  }
357  void waitForNotificationsIfTipChanged(const uint256& old_tip) override
358  {
359  if (!old_tip.IsNull()) {
360  LOCK(::cs_main);
361  if (old_tip == ::ChainActive().Tip()->GetBlockHash()) return;
362  }
364  }
365  std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
366  {
367  return MakeUnique<RpcHandlerImpl>(command);
368  }
369  bool rpcEnableDeprecated(const std::string& method) override { return IsDeprecatedRPCEnabled(method); }
370  void rpcRunLater(const std::string& name, std::function<void()> fn, int64_t seconds) override
371  {
372  RPCRunLater(name, std::move(fn), seconds);
373  }
374  int rpcSerializationFlags() override { return RPCSerializationFlags(); }
375  void requestMempoolTransactions(Notifications& notifications) override
376  {
377  LOCK2(::cs_main, ::mempool.cs);
378  for (const CTxMemPoolEntry& entry : ::mempool.mapTx) {
379  notifications.transactionAddedToMempool(entry.GetSharedTx());
380  }
381  }
383 };
384 } // namespace
385 
386 std::unique_ptr<Chain> MakeChain(NodeContext& node) { return MakeUnique<ChainImpl>(node); }
387 
388 } // namespace interfaces
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:387
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT
Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors.
Definition: validation.h:60
CTxMemPool mempool
bool ShutdownRequested()
Definition: shutdown.cpp:20
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
static const unsigned int DEFAULT_DESCENDANT_LIMIT
Default for -limitdescendantcount, max number of in-mempool descendants.
Definition: validation.h:62
Optional< txiter > GetIter(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
Definition: txmempool.cpp:875
int64_t GetBlockTime() const
Definition: chain.h:247
Describes a place in the block chain to another node such that if the other node doesn&#39;t have the sam...
Definition: block.h:114
RBFTransactionState IsRBFOptIn(const CTransaction &tx, const CTxMemPool &pool)
Definition: rbf.cpp:8
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
Definition: chain.h:174
Bilingual messages:
Definition: translation.h:16
Actor actor
Definition: server.h:114
CChain & ChainActive()
Please prefer the identical ChainstateManager::ActiveChain.
Definition: validation.cpp:112
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE
Default for -maxmempool, maximum megabytes of mempool memory usage.
Definition: policy.h:32
bool fHavePruned
Pruning-related variables and constants.
Definition: validation.cpp:137
NodeContext & m_node
Definition: chain.cpp:382
void InitWarning(const bilingual_str &str)
Show warning message.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
static const unsigned int DEFAULT_ANCESTOR_LIMIT
Default for -limitancestorcount, max number of in-mempool ancestors.
Definition: validation.h:58
const CBlockIndex * LastCommonAncestor(const CBlockIndex *pa, const CBlockIndex *pb)
Find the last common ancestor two blocks have.
Definition: chain.cpp:156
int Height() const
Return the maximal height in the chain.
Definition: chain.h:421
bool removeCommand(const std::string &name, const CRPCCommand *pcmd)
Definition: server.cpp:274
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:531
static auto & nullopt
Substitute for C++17 std::nullopt.
Definition: optional.h:24
bool isNum() const
Definition: univalue.h:82
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal...
Definition: txmempool.h:348
void RegisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Register subscriber.
#define REVERSE_LOCK(g)
Definition: sync.h:221
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
Definition: server.cpp:502
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:265
void UnregisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Unregister subscriber.
Implement this to subscribe to events generated in validation.
bool IsNull() const
Definition: uint256.h:30
std::unique_ptr< Chain > MakeChain(NodeContext &node)
Return implementation of Chain interface.
Definition: chain.cpp:386
RBFTransactionState
Definition: rbf.h:10
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition: txmempool.h:64
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
uint256 GetBlockHash() const
Definition: chain.h:233
CBlockPolicyEstimator feeEstimator
Definition: validation.cpp:151
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:62
#define LOCK2(cs1, cs2)
Definition: sync.h:227
std::string name
Definition: server.h:113
CRPCTable tableRPC
Definition: server.cpp:520
bool CheckFinalTx(const CTransaction &tx, int flags)
Transaction validation functions.
Definition: validation.cpp:210
NodeContext struct containing references to chain state and connection state.
Definition: context.h:34
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
Definition: validation.cpp:149
#define LOCK(cs)
Definition: sync.h:226
const char * name
Definition: rest.cpp:41
CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, bool conservative) const
Estimate feerate needed to get be included in a block within confTarget blocks.
Definition: fees.cpp:785
CTransactionRef GetSharedTx() const
Definition: txmempool.h:98
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Definition: validation.cpp:128
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT
Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants.
Definition: validation.h:64
int64_t GetBlockTimeMax() const
Definition: chain.h:252
const CRPCCommand * m_wrapped_command
Definition: chain.cpp:141
bool InitError(const bilingual_str &str)
Show error message.
#define WAIT_LOCK(cs, name)
Definition: sync.h:231
std::atomic_bool fImporting
int get_int() const
bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntries &setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString, bool fSearchForParents=true) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Try to calculate all in-mempool ancestors of entry.
Definition: txmempool.cpp:152
Invalid wallet specified.
Definition: protocol.h:79
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
Definition: txmempool.cpp:1003
bool IsDeprecatedRPCEnabled(const std::string &method)
Definition: server.cpp:349
int64_t GetMedianTimePast() const
Definition: chain.h:259
CFeeRate incrementalRelayFee
Definition: settings.cpp:12
CRPCCommand m_command
Definition: chain.cpp:140
std::atomic_bool fReindex
CBlockIndex * LookupBlockIndex(const uint256 &hash)
Definition: validation.cpp:174
unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const
Calculation of highest target that estimates are tracked for.
Definition: fees.cpp:675
256-bit opaque blob.
Definition: uint256.h:120
TransactionError BroadcastTransaction(NodeContext &node, const CTransactionRef tx, std::string &err_string, const CAmount &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:16
CChainState & ChainstateActive()
Please prefer the identical ChainstateManager::ActiveChainstate.
Definition: validation.cpp:105
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:137
const CChainParams & Params()
Return the currently selected parameters.
int RPCSerializationFlags()
Definition: server.cpp:512
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...
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:380
CBlockIndex * FindForkInGlobalIndex(const CChain &chain, const CBlockLocator &locator)
Find the last common block between the parameter chain and a locator.
Definition: validation.cpp:181
int64_t GetAdjustedTime()
Definition: timedata.cpp:34
std::shared_ptr< Chain::Notifications > m_notifications
Definition: chain.cpp:83
bool IsInitialBlockDownload() const
Check whether we are doing an initial block download (synchronizing from disk or network) ...
ArgsManager gArgs
Definition: system.cpp:77
TransactionError
Definition: error.h:22
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
void FindCoins(const NodeContext &node, std::map< COutPoint, Coin > &coins)
Look up unspent output information.
Definition: coin.cpp:11
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:23
Wrapper around std::unique_lock style lock for Mutex.
Definition: sync.h:129
CClientUIInterface uiInterface
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:251
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:150
boost::optional< T > Optional
Substitute for C++17 std::optional.
Definition: optional.h:14
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
Definition: chain.cpp:111
full block available in blk*.dat
Definition: chain.h:121
auto it
Definition: validation.cpp:384
std::shared_ptr< NotificationsProxy > m_proxy
Definition: chain.cpp:102
CFeeRate dustRelayFee
Definition: settings.cpp:13
unsigned int nTx
Number of transactions in this block.
Definition: chain.h:166
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
Definition: txmempool.h:520
void GetTransactionAncestry(const uint256 &txid, size_t &ancestors, size_t &descendants) const
Calculate the ancestor and descendant count for the given transaction.
Definition: txmempool.cpp:1100
LockPoints lp