lbrycrd/src/rpc/blockchain.h
Marcin Jachymiak 4b7091a842 Replace median fee rate with feerate percentiles
Removes medianfeerate result from getblockstats.
Adds feerate_percentiles which give the feerate of the 10th, 25th, 50th,
75th, and 90th percentile weight unit in the block.
2018-08-11 15:00:17 -04:00

46 lines
1.4 KiB
C++

// Copyright (c) 2017-2018 The Bitcoin Core developers
// 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
#include <vector>
#include <stdint.h>
#include <amount.h>
class CBlock;
class CBlockIndex;
class UniValue;
static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
/**
* 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).
*/
double GetDifficulty(const CBlockIndex* blockindex);
/** Callback for when block tip changed. */
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
/** 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);
/** 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);
#endif