Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,728 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 2) { | ||||
"transactions in the chain.\n" | "transactions in the chain.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. nblocks (numeric, optional) Size of the window in number " | "1. nblocks (numeric, optional) Size of the window in number " | ||||
"of blocks (default: one month).\n" | "of blocks (default: one month).\n" | ||||
"2. \"blockhash\" (string, optional) The hash of the block that " | "2. \"blockhash\" (string, optional) The hash of the block that " | ||||
"ends the window.\n" | "ends the window.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"time\": xxxxx, (numeric) The timestamp for the " | " \"time\": xxxxx, (numeric) The " | ||||
"final block in the window in UNIX format.\n" | "timestamp for the final block in the window in UNIX format.\n" | ||||
" \"txcount\": xxxxx, (numeric) The total number of " | " \"txcount\": xxxxx, (numeric) The total " | ||||
"transactions in the chain up to that point.\n" | "number of transactions in the chain up to that point.\n" | ||||
" \"window_block_count\": xxxxx, (numeric) Size of the window in " | " \"window_final_block_hash\": \"...\", (string) The hash of " | ||||
"number of blocks.\n" | "the final block in the window.\n" | ||||
" \"window_tx_count\": xxxxx, (numeric) The number of " | " \"window_block_count\": xxxxx, (numeric) Size of " | ||||
"transactions in the window. Only returned if " | "the window in number of blocks.\n" | ||||
" \"window_tx_count\": xxxxx, (numeric) The number " | |||||
"of transactions in the window. Only returned if " | |||||
"\"window_block_count\" is > 0.\n" | "\"window_block_count\" is > 0.\n" | ||||
" \"window_interval\": xxxxx, (numeric) The elapsed time in " | " \"window_interval\": xxxxx, (numeric) The elapsed " | ||||
"the window in seconds. Only returned if \"window_block_count\" is " | "time in the window in seconds. Only returned if " | ||||
"> 0.\n" | "\"window_block_count\" is > 0.\n" | ||||
" \"txrate\": x.xx, (numeric) The average rate of " | " \"txrate\": x.xx, (numeric) The average " | ||||
"transactions per second in the window. Only returned if " | "rate of transactions per second in the window. Only returned if " | ||||
"\"window_interval\" is > 0.\n" | "\"window_interval\" is > 0.\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getchaintxstats", "") + | HelpExampleCli("getchaintxstats", "") + | ||||
HelpExampleRpc("getchaintxstats", "2016")); | HelpExampleRpc("getchaintxstats", "2016")); | ||||
} | } | ||||
const CBlockIndex *pindex; | const CBlockIndex *pindex; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | const CBlockIndex *pindexPast = | ||||
pindex->GetAncestor(pindex->nHeight - blockcount); | pindex->GetAncestor(pindex->nHeight - blockcount); | ||||
int nTimeDiff = | int nTimeDiff = | ||||
pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast(); | pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast(); | ||||
int nTxDiff = pindex->nChainTx - pindexPast->nChainTx; | int nTxDiff = pindex->nChainTx - pindexPast->nChainTx; | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
ret.pushKV("time", int64_t(pindex->nTime)); | ret.pushKV("time", int64_t(pindex->nTime)); | ||||
ret.pushKV("txcount", int64_t(pindex->nChainTx)); | ret.pushKV("txcount", int64_t(pindex->nChainTx)); | ||||
ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex()); | |||||
ret.pushKV("window_block_count", blockcount); | ret.pushKV("window_block_count", blockcount); | ||||
if (blockcount > 0) { | if (blockcount > 0) { | ||||
ret.pushKV("window_tx_count", nTxDiff); | ret.pushKV("window_tx_count", nTxDiff); | ||||
ret.pushKV("window_interval", nTimeDiff); | ret.pushKV("window_interval", nTimeDiff); | ||||
if (nTimeDiff > 0) { | if (nTimeDiff > 0) { | ||||
ret.pushKV("txrate", double(nTxDiff) / nTimeDiff); | ret.pushKV("txrate", double(nTxDiff) / nTimeDiff); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |