2022-12-24 23:49:50 +00:00
|
|
|
// Copyright (c) 2017-2022 The Bitcoin Core developers
|
2017-03-27 12:14:43 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_RPC_BLOCKCHAIN_H
|
|
|
|
#define BITCOIN_RPC_BLOCKCHAIN_H
|
|
|
|
|
2021-09-11 10:29:00 +08:00
|
|
|
#include <consensus/amount.h>
|
2021-02-27 17:39:09 +00:00
|
|
|
#include <core_io.h>
|
2020-08-25 13:46:58 -04:00
|
|
|
#include <streams.h>
|
2019-05-02 14:34:09 -04:00
|
|
|
#include <sync.h>
|
2023-03-15 11:18:06 +01:00
|
|
|
#include <util/fs.h>
|
2020-12-24 20:06:34 -05:00
|
|
|
#include <validation.h>
|
2019-05-02 14:34:09 -04:00
|
|
|
|
2020-12-01 00:36:36 +01:00
|
|
|
#include <any>
|
2019-05-02 14:34:09 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-03-27 16:12:02 +02:00
|
|
|
class CBlock;
|
2017-03-27 12:14:43 +02:00
|
|
|
class CBlockIndex;
|
2022-03-09 12:37:19 -05:00
|
|
|
class Chainstate;
|
2017-03-27 16:12:02 +02:00
|
|
|
class UniValue;
|
2021-11-12 10:06:00 -05:00
|
|
|
namespace node {
|
2019-09-17 19:05:26 -04:00
|
|
|
struct NodeContext;
|
2021-11-12 10:06:00 -05:00
|
|
|
} // namespace node
|
2017-03-27 12:14:43 +02:00
|
|
|
|
2018-08-08 14:40:56 -04:00
|
|
|
static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
|
|
|
|
|
2017-03-27 12:14:43 +02:00
|
|
|
/**
|
2018-09-03 09:35:41 +08:00
|
|
|
* Get the difficulty of the net wrt to the given block index.
|
2017-03-27 12:14:43 +02:00
|
|
|
*
|
|
|
|
* @return A floating point number that is a multiple of the main net minimum
|
|
|
|
* difficulty (4295032833 hashes).
|
|
|
|
*/
|
2018-05-20 14:04:15 -07:00
|
|
|
double GetDifficulty(const CBlockIndex* blockindex);
|
2017-03-27 12:14:43 +02:00
|
|
|
|
2017-03-27 16:04:31 +02:00
|
|
|
/** Callback for when block tip changed. */
|
2020-03-04 19:48:32 +02:00
|
|
|
void RPCNotifyBlockChange(const CBlockIndex*);
|
2017-03-27 16:04:31 +02:00
|
|
|
|
2017-03-27 16:12:02 +02:00
|
|
|
/** Block description to JSON */
|
2020-12-24 20:06:34 -05:00
|
|
|
UniValue blockToJSON(node::BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, TxVerbosity verbosity) LOCKS_EXCLUDED(cs_main);
|
2017-03-27 16:12:02 +02:00
|
|
|
|
|
|
|
/** Block header to JSON */
|
2019-05-02 14:34:09 -04:00
|
|
|
UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex) LOCKS_EXCLUDED(cs_main);
|
2017-03-27 16:12:02 +02:00
|
|
|
|
2018-08-08 14:40:56 -04:00
|
|
|
/** Used by getblockstats to get feerates at different percentiles by weight */
|
|
|
|
void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_weight);
|
|
|
|
|
2020-08-25 13:46:58 -04:00
|
|
|
/**
|
|
|
|
* Helper to create UTXO snapshots given a chainstate and a file handle.
|
|
|
|
* @return a UniValue map containing metadata about the snapshot.
|
|
|
|
*/
|
2019-04-25 11:09:57 -04:00
|
|
|
UniValue CreateUTXOSnapshot(
|
2021-11-12 10:06:00 -05:00
|
|
|
node::NodeContext& node,
|
2022-03-09 12:37:19 -05:00
|
|
|
Chainstate& chainstate,
|
2022-06-06 17:22:59 +02:00
|
|
|
AutoFile& afile,
|
2019-04-25 11:09:57 -04:00
|
|
|
const fs::path& path,
|
|
|
|
const fs::path& tmppath);
|
2020-08-25 13:46:58 -04:00
|
|
|
|
2021-11-12 11:19:44 +01:00
|
|
|
#endif // BITCOIN_RPC_BLOCKCHAIN_H
|