Bitcoin Core  21.99.0
P2P Digital Currency
Functions | Variables
blockchain.h File Reference
#include <amount.h>
#include <core_io.h>
#include <streams.h>
#include <sync.h>
#include <any>
#include <stdint.h>
#include <vector>
Include dependency graph for blockchain.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

double GetDifficulty (const CBlockIndex *blockindex)
 Get the difficulty of the net wrt to the given block index. More...
 
void RPCNotifyBlockChange (const CBlockIndex *)
 Callback for when block tip changed. More...
 
UniValue blockToJSON (const CBlock &block, const CBlockIndex *tip, const CBlockIndex *blockindex, bool txDetails=false) LOCKS_EXCLUDED(cs_main)
 Block description to JSON. More...
 
UniValue MempoolInfoToJSON (const CTxMemPool &pool)
 Mempool information to JSON. More...
 
UniValue MempoolToJSON (const CTxMemPool &pool, bool verbose=false, bool include_mempool_sequence=false)
 Mempool to JSON. More...
 
UniValue blockheaderToJSON (const CBlockIndex *tip, const CBlockIndex *blockindex) LOCKS_EXCLUDED(cs_main)
 Block header to JSON. More...
 
void CalculatePercentilesByWeight (CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector< std::pair< CAmount, int64_t >> &scores, int64_t total_weight)
 Used by getblockstats to get feerates at different percentiles by weight
More...
 
void ScriptPubKeyToUniv (const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
 
void TxToUniv (const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr)
 
NodeContextEnsureAnyNodeContext (const std::any &context)
 
CTxMemPoolEnsureMemPool (const NodeContext &node)
 
CTxMemPoolEnsureAnyMemPool (const std::any &context)
 
ChainstateManagerEnsureChainman (const NodeContext &node)
 
ChainstateManagerEnsureAnyChainman (const std::any &context)
 
CBlockPolicyEstimatorEnsureFeeEstimator (const NodeContext &node)
 
CBlockPolicyEstimatorEnsureAnyFeeEstimator (const std::any &context)
 
UniValue CreateUTXOSnapshot (NodeContext &node, CChainState &chainstate, CAutoFile &afile)
 Helper to create UTXO snapshots given a chainstate and a file handle. More...
 

Variables

RecursiveMutex cs_main
 Mutex to guard access to validation specific variables, such as reading or changing the chainstate. More...
 
static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5
 

Function Documentation

◆ blockheaderToJSON()

UniValue blockheaderToJSON ( const CBlockIndex tip,
const CBlockIndex blockindex 
)

Block header to JSON.

Definition at line 169 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blockToJSON()

UniValue blockToJSON ( const CBlock block,
const CBlockIndex tip,
const CBlockIndex blockindex,
bool  txDetails = false 
)

Block description to JSON.

Definition at line 198 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculatePercentilesByWeight()

void CalculatePercentilesByWeight ( CAmount  result[NUM_GETBLOCKSTATS_PERCENTILES],
std::vector< std::pair< CAmount, int64_t >> &  scores,
int64_t  total_weight 
)

Used by getblockstats to get feerates at different percentiles by weight

Definition at line 1897 of file blockchain.cpp.

Here is the caller graph for this function:

◆ CreateUTXOSnapshot()

UniValue CreateUTXOSnapshot ( NodeContext node,
CChainState chainstate,
CAutoFile afile 
)

Helper to create UTXO snapshots given a chainstate and a file handle.

Returns
a UniValue map containing metadata about the snapshot.

Definition at line 2566 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureAnyChainman()

ChainstateManager& EnsureAnyChainman ( const std::any &  context)

Definition at line 90 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureAnyFeeEstimator()

CBlockPolicyEstimator& EnsureAnyFeeEstimator ( const std::any &  context)

Definition at line 103 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureAnyMemPool()

CTxMemPool& EnsureAnyMemPool ( const std::any &  context)

Definition at line 77 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureAnyNodeContext()

NodeContext& EnsureAnyNodeContext ( const std::any &  context)

Definition at line 60 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureChainman()

ChainstateManager& EnsureChainman ( const NodeContext node)

Definition at line 82 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureFeeEstimator()

CBlockPolicyEstimator& EnsureFeeEstimator ( const NodeContext node)

Definition at line 95 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureMemPool()

CTxMemPool& EnsureMemPool ( const NodeContext node)

Definition at line 69 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDifficulty()

double GetDifficulty ( const CBlockIndex blockindex)

Get the difficulty of the net wrt to the given block index.

Returns
A floating point number that is a multiple of the main net minimum difficulty (4295032833 hashes).

Definition at line 110 of file blockchain.cpp.

Here is the caller graph for this function:

◆ MempoolInfoToJSON()

UniValue MempoolInfoToJSON ( const CTxMemPool pool)

Mempool information to JSON.

Definition at line 1633 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MempoolToJSON()

UniValue MempoolToJSON ( const CTxMemPool pool,
bool  verbose = false,
bool  include_mempool_sequence = false 
)

Mempool to JSON.

Definition at line 541 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RPCNotifyBlockChange()

void RPCNotifyBlockChange ( const CBlockIndex )

Callback for when block tip changed.

Definition at line 268 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScriptPubKeyToUniv()

void ScriptPubKeyToUniv ( const CScript scriptPubKey,
UniValue out,
bool  fIncludeHex 
)

Definition at line 1926 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TxToUniv()

void TxToUniv ( const CTransaction tx,
const uint256 hashBlock,
UniValue entry,
bool  include_hex = true,
int  serialize_flags = 0,
const CTxUndo txundo = nullptr 
)

Definition at line 1931 of file blockchain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cs_main

RecursiveMutex cs_main

Mutex to guard access to validation specific variables, such as reading or changing the chainstate.

This may also need to be locked when updating the transaction pool, e.g. on AcceptToMemoryPool. See CTxMemPool::cs comment for details.

The transaction pool has a separate lock to allow reading from it and the chainstate at the same time.

Definition at line 114 of file validation.cpp.

◆ NUM_GETBLOCKSTATS_PERCENTILES

constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5
staticconstexpr

Definition at line 28 of file blockchain.h.