aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/blockchain.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-08-13 07:18:00 -0400
committerMarcoFalke <falke.marco@gmail.com>2018-08-13 07:18:25 -0400
commita9c56b663439039b683f6ca2bcab12aab7c71366 (patch)
tree382060e6592c12cb13d74b8607fd189baf49319d /src/rpc/blockchain.h
parentef86f2631e3ce5e1664e1913658fa6e807f35ff7 (diff)
parent4b7091a842c2c3a76f4136cb0fdcf1c5904fd237 (diff)
downloadbitcoin-a9c56b663439039b683f6ca2bcab12aab7c71366.tar.xz
Merge #13918: rpc: Replace median fee rate with feerate percentiles in getblockstats
4b7091a842 Replace median fee rate with feerate percentiles (Marcin Jachymiak) Pull request description: Currently, the `medianfeerate` statistic is calculated from the feerate of the middle transaction of a list of transactions sorted by feerate. This PR instead uses the value of the 50th percentile weight unit in the block, and also calculates the feerate at the 10th, 25th, 75th, and 90th percentiles. This more accurately corresponds with what is generally meant by median feerate. Tree-SHA512: 59255e243df90d7afbe69839408c58c9723884b8ab82c66dc24a769e89c6d539db1905374a3f025ff28272fb25a0b90e92d8101103e39a6d9c0d60423a596714
Diffstat (limited to 'src/rpc/blockchain.h')
-rw-r--r--src/rpc/blockchain.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h
index c664139ed3..544bc62c36 100644
--- a/src/rpc/blockchain.h
+++ b/src/rpc/blockchain.h
@@ -5,10 +5,16 @@
#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.
@@ -33,4 +39,7 @@ 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