Bitcoin Core 28.99.0
P2P Digital Currency
blockchain.h
Go to the documentation of this file.
1// Copyright (c) 2017-2022 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 <streams.h>
11#include <sync.h>
12#include <util/fs.h>
13#include <validation.h>
14
15#include <any>
16#include <stdint.h>
17#include <vector>
18
19class CBlock;
20class CBlockIndex;
21class Chainstate;
22class UniValue;
23namespace node {
24class BlockManager;
25struct NodeContext;
26} // namespace node
27
28static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
29
36double GetDifficulty(const CBlockIndex& blockindex);
37
39UniValue blockToJSON(node::BlockManager& blockman, const CBlock& block, const CBlockIndex& tip, const CBlockIndex& blockindex, TxVerbosity verbosity) LOCKS_EXCLUDED(cs_main);
40
43
45void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_weight);
46
53 Chainstate& chainstate,
54 AutoFile& afile,
55 const fs::path& path,
56 const fs::path& tmppath);
57
59std::optional<int> GetPruneHeight(const node::BlockManager& blockman, const CChain& chain) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
60void CheckBlockDataAvailability(node::BlockManager& blockman, const CBlockIndex& blockindex, bool check_for_undo) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
61
62#endif // BITCOIN_RPC_BLOCKCHAIN_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
void CheckBlockDataAvailability(BlockManager &blockman, const CBlockIndex &blockindex, bool check_for_undo)
Definition: blockchain.cpp:604
std::optional< int > GetPruneHeight(const BlockManager &blockman, const CChain &chain)
Return height of highest block that has been pruned, or std::nullopt if no blocks have been pruned.
Definition: blockchain.cpp:811
UniValue blockToJSON(node::BlockManager &blockman, const CBlock &block, const CBlockIndex &tip, const CBlockIndex &blockindex, TxVerbosity verbosity) LOCKS_EXCLUDED(cs_main)
Block description to JSON.
Definition: blockchain.cpp:178
static constexpr int NUM_GETBLOCKSTATS_PERCENTILES
Definition: blockchain.h:28
double GetDifficulty(const CBlockIndex &blockindex)
Get the difficulty of the net wrt to the given block index.
Definition: blockchain.cpp:91
UniValue CreateUTXOSnapshot(node::NodeContext &node, Chainstate &chainstate, AutoFile &afile, const fs::path &path, const fs::path &tmppath)
Test-only helper to create UTXO snapshots given a chainstate and a file handle.
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
UniValue blockheaderToJSON(const CBlockIndex &tip, const CBlockIndex &blockindex) LOCKS_EXCLUDED(cs_main)
Block header to JSON.
Definition: blockchain.cpp:149
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:392
Definition: block.h:69
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:141
An in-memory indexed chain of blocks.
Definition: chain.h:417
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:505
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:33
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: blockstorage.h:136
TxVerbosity
Verbose level for block's transaction.
Definition: core_io.h:28
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:8
Definition: messages.h:20
NodeContext struct containing references to chain state and connection state.
Definition: context.h:56
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:48