MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / getblockstats

Function getblockstats

src/rpc/blockchain.cpp:1777–2040  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1775static constexpr size_t PER_UTXO_OVERHEAD = sizeof(COutPoint) + sizeof(uint32_t) + sizeof(bool);
1776
1777static UniValue getblockstats(const JSONRPCRequest& request)
1778{
1779 if (request.fHelp || request.params.size() < 1 || request.params.size() > 4) {
1780 throw std::runtime_error(
1781 "getblockstats hash_or_height ( stats )\n"
1782 "\nCompute per block statistics for a given window. All amounts are in satoshis.\n"
1783 "It won't work for some heights with pruning.\n"
1784 "It won't work without -txindex for utxo_size_inc, *fee or *feerate stats.\n"
1785 "\nArguments:\n"
1786 "1. \"hash_or_height\" (string or numeric, required) The block hash or height of the target block\n"
1787 "2. \"stats\" (array, optional) Values to plot, by default all values (see result below)\n"
1788 " [\n"
1789 " \"height\", (string, optional) Selected statistic\n"
1790 " \"time\", (string, optional) Selected statistic\n"
1791 " ,...\n"
1792 " ]\n"
1793 "\nResult:\n"
1794 "{ (json object)\n"
1795 " \"avgfee\": xxxxx, (numeric) Average fee in the block\n"
1796 " \"avgfeerate\": xxxxx, (numeric) Average feerate (in satoshis per virtual byte)\n"
1797 " \"avgtxsize\": xxxxx, (numeric) Average transaction size\n"
1798 " \"blockhash\": xxxxx, (string) The block hash (to check for potential reorgs)\n"
1799 " \"feerate_percentiles\": [ (array of numeric) Feerates at the 10th, 25th, 50th, 75th, and 90th percentile weight unit (in satoshis per virtual byte)\n"
1800 " \"10th_percentile_feerate\", (numeric) The 10th percentile feerate\n"
1801 " \"25th_percentile_feerate\", (numeric) The 25th percentile feerate\n"
1802 " \"50th_percentile_feerate\", (numeric) The 50th percentile feerate\n"
1803 " \"75th_percentile_feerate\", (numeric) The 75th percentile feerate\n"
1804 " \"90th_percentile_feerate\", (numeric) The 90th percentile feerate\n"
1805 " ],\n"
1806 " \"height\": xxxxx, (numeric) The height of the block\n"
1807 " \"ins\": xxxxx, (numeric) The number of inputs (excluding coinbase)\n"
1808 " \"maxfee\": xxxxx, (numeric) Maximum fee in the block\n"
1809 " \"maxfeerate\": xxxxx, (numeric) Maximum feerate (in satoshis per virtual byte)\n"
1810 " \"maxtxsize\": xxxxx, (numeric) Maximum transaction size\n"
1811 " \"medianfee\": xxxxx, (numeric) Truncated median fee in the block\n"
1812 " \"mediantime\": xxxxx, (numeric) The block median time past\n"
1813 " \"mediantxsize\": xxxxx, (numeric) Truncated median transaction size\n"
1814 " \"minfee\": xxxxx, (numeric) Minimum fee in the block\n"
1815 " \"minfeerate\": xxxxx, (numeric) Minimum feerate (in satoshis per virtual byte)\n"
1816 " \"mintxsize\": xxxxx, (numeric) Minimum transaction size\n"
1817 " \"outs\": xxxxx, (numeric) The number of outputs\n"
1818 " \"subsidy\": xxxxx, (numeric) The block subsidy\n"
1819 " \"swtotal_size\": xxxxx, (numeric) Total size of all segwit transactions\n"
1820 " \"swtotal_weight\": xxxxx, (numeric) Total weight of all segwit transactions divided by segwit scale factor (4)\n"
1821 " \"swtxs\": xxxxx, (numeric) The number of segwit transactions\n"
1822 " \"time\": xxxxx, (numeric) The block time\n"
1823 " \"total_out\": xxxxx, (numeric) Total amount in all outputs (excluding coinbase and thus reward [ie subsidy + totalfee])\n"
1824 " \"total_size\": xxxxx, (numeric) Total size of all non-coinbase transactions\n"
1825 " \"total_weight\": xxxxx, (numeric) Total weight of all non-coinbase transactions divided by segwit scale factor (4)\n"
1826 " \"totalfee\": xxxxx, (numeric) The fee total\n"
1827 " \"txs\": xxxxx, (numeric) The number of transactions (excluding coinbase)\n"
1828 " \"utxo_increase\": xxxxx, (numeric) The increase/decrease in the number of unspent outputs\n"
1829 " \"utxo_size_inc\": xxxxx, (numeric) The increase/decrease in size for the utxo index (not discounting op_return and similar)\n"
1830 "}\n"
1831 "\nExamples:\n"
1832 + HelpExampleCli("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'")
1833 + HelpExampleRpc("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'")
1834 );

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
uint256SFunction · 0.85
LookupBlockIndexFunction · 0.85
GetBlockCheckedFunction · 0.85
SetHasKeysFunction · 0.85
GetSerializeSizeFunction · 0.85
maxFunction · 0.85
GetTransactionWeightFunction · 0.85
GetTransactionFunction · 0.85
MoneyRangeFunction · 0.85

Tested by

no test coverage detected