2018-07-27 00:36:45 +02:00
|
|
|
// Copyright (c) 2017-2018 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
|
|
|
|
|
2018-08-08 20:40:56 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <amount.h>
|
|
|
|
|
2017-03-27 16:12:02 +02:00
|
|
|
class CBlock;
|
2017-03-27 12:14:43 +02:00
|
|
|
class CBlockIndex;
|
2017-03-27 16:12:02 +02:00
|
|
|
class UniValue;
|
2017-03-27 12:14:43 +02:00
|
|
|
|
2018-08-08 20:40:56 +02:00
|
|
|
static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
|
|
|
|
|
2017-03-27 12:14:43 +02:00
|
|
|
/**
|
|
|
|
* Get the difficulty of the net wrt to the given block index, or the chain tip if
|
|
|
|
* not provided.
|
|
|
|
*
|
|
|
|
* @return A floating point number that is a multiple of the main net minimum
|
|
|
|
* difficulty (4295032833 hashes).
|
|
|
|
*/
|
2018-05-20 23:04:15 +02: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. */
|
|
|
|
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
|
|
|
|
|
2017-03-27 16:12:02 +02:00
|
|
|
/** Block description to JSON */
|
|
|
|
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
|
|
|
|
|
|
|
|
/** Mempool information to JSON */
|
|
|
|
UniValue mempoolInfoToJSON();
|
|
|
|
|
|
|
|
/** Mempool to JSON */
|
|
|
|
UniValue mempoolToJSON(bool fVerbose = false);
|
|
|
|
|
|
|
|
/** Block header to JSON */
|
|
|
|
UniValue blockheaderToJSON(const CBlockIndex* blockindex);
|
|
|
|
|
2018-08-08 20:40:56 +02: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);
|
|
|
|
|
2017-03-27 12:14:43 +02:00
|
|
|
#endif
|