Bitcoin Core  22.99.0
P2P Digital Currency
blockchain.h
Go to the documentation of this file.
1 // Copyright (c) 2017-2021 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 #ifndef BITCOIN_RPC_BLOCKCHAIN_H
6 #define BITCOIN_RPC_BLOCKCHAIN_H
7 
8 #include <consensus/amount.h>
9 #include <core_io.h>
10 #include <fs.h>
11 #include <streams.h>
12 #include <sync.h>
13 
14 #include <any>
15 #include <stdint.h>
16 #include <vector>
17 
18 extern RecursiveMutex cs_main;
19 
20 class CBlock;
21 class CBlockIndex;
22 class CChainState;
23 class CTxMemPool;
24 class UniValue;
25 namespace node {
26 struct NodeContext;
27 } // namespace node
28 
29 static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
30 
37 double GetDifficulty(const CBlockIndex* blockindex);
38 
41 
43 UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, TxVerbosity verbosity) LOCKS_EXCLUDED(cs_main);
44 
47 
49 UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose = false, bool include_mempool_sequence = false);
50 
53 
55 void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_weight);
56 
63  CChainState& chainstate,
64  CAutoFile& afile,
65  const fs::path& path,
66  const fs::path& tmppath);
67 
68 #endif // BITCOIN_RPC_BLOCKCHAIN_H
fs.h
streams.h
sync.h
NUM_GETBLOCKSTATS_PERCENTILES
static constexpr int NUM_GETBLOCKSTATS_PERCENTILES
Definition: blockchain.h:29
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:429
MempoolInfoToJSON
UniValue MempoolInfoToJSON(const CTxMemPool &pool)
Mempool information to JSON.
Definition: blockchain.cpp:1812
node::NodeContext
NodeContext struct containing references to chain state and connection state.
Definition: context.h:40
GetDifficulty
double GetDifficulty(const CBlockIndex *blockindex)
Get the difficulty of the net wrt to the given block index.
Definition: blockchain.cpp:81
blockheaderToJSON
UniValue blockheaderToJSON(const CBlockIndex *tip, const CBlockIndex *blockindex) LOCKS_EXCLUDED(cs_main)
Block header to JSON.
Definition: blockchain.cpp:140
AnnotatedMixin< std::recursive_mutex >
MempoolToJSON
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose=false, bool include_mempool_sequence=false)
Mempool to JSON.
Definition: blockchain.cpp:536
core_io.h
UniValue
Definition: univalue.h:17
CAutoFile
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:478
fs::path
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:29
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
blockToJSON
UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, const CBlockIndex *blockindex, TxVerbosity verbosity) LOCKS_EXCLUDED(cs_main)
Block description to JSON.
Definition: blockchain.cpp:169
CreateUTXOSnapshot
UniValue CreateUTXOSnapshot(node::NodeContext &node, CChainState &chainstate, CAutoFile &afile, const fs::path &path, const fs::path &tmppath)
Helper to create UTXO snapshots given a chainstate and a file handle.
Definition: blockchain.cpp:2754
RPCNotifyBlockChange
void RPCNotifyBlockChange(const CBlockIndex *)
Callback for when block tip changed.
Definition: blockchain.cpp:247
CChainState
CChainState stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:459
CBlock
Definition: block.h:62
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: blockchain.cpp:2076
LOCKS_EXCLUDED
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:138
node
Definition: init.h:22
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:151
amount.h
TxVerbosity
TxVerbosity
Verbose level for block's transaction.
Definition: core_io.h:26