Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 2,192 Lines • ▼ Show 20 Lines | const bool loop_inputs = | ||||
do_all || do_medianfee || do_medianfeerate || | do_all || do_medianfee || do_medianfeerate || | ||||
SetHasKeys(stats, "utxo_size_inc", "totalfee", "avgfee", "avgfeerate", | SetHasKeys(stats, "utxo_size_inc", "totalfee", "avgfee", "avgfeerate", | ||||
"minfee", "maxfee", "minfeerate", "maxfeerate"); | "minfee", "maxfee", "minfeerate", "maxfeerate"); | ||||
const bool loop_outputs = do_all || loop_inputs || stats.count("total_out"); | const bool loop_outputs = do_all || loop_inputs || stats.count("total_out"); | ||||
const bool do_calculate_size = | const bool do_calculate_size = | ||||
do_mediantxsize || loop_inputs || | do_mediantxsize || loop_inputs || | ||||
SetHasKeys(stats, "total_size", "avgtxsize", "mintxsize", "maxtxsize"); | SetHasKeys(stats, "total_size", "avgtxsize", "mintxsize", "maxtxsize"); | ||||
if (loop_inputs && !g_txindex) { | |||||
throw JSONRPCError( | |||||
RPC_INVALID_PARAMETER, | |||||
"One or more of the selected stats requires -txindex enabled"); | |||||
} | |||||
const int64_t blockMaxSize = config.GetMaxBlockSize(); | const int64_t blockMaxSize = config.GetMaxBlockSize(); | ||||
Amount maxfee = Amount::zero(); | Amount maxfee = Amount::zero(); | ||||
Amount maxfeerate = Amount::zero(); | Amount maxfeerate = Amount::zero(); | ||||
Amount minfee = MAX_MONEY; | Amount minfee = MAX_MONEY; | ||||
Amount minfeerate = MAX_MONEY; | Amount minfeerate = MAX_MONEY; | ||||
Amount total_out = Amount::zero(); | Amount total_out = Amount::zero(); | ||||
Amount totalfee = Amount::zero(); | Amount totalfee = Amount::zero(); | ||||
int64_t inputs = 0; | int64_t inputs = 0; | ||||
Show All 35 Lines | for (const auto &tx : block.vtx) { | ||||
txsize_array.push_back(tx_size); | txsize_array.push_back(tx_size); | ||||
} | } | ||||
maxtxsize = std::max(maxtxsize, tx_size); | maxtxsize = std::max(maxtxsize, tx_size); | ||||
mintxsize = std::min(mintxsize, tx_size); | mintxsize = std::min(mintxsize, tx_size); | ||||
total_size += tx_size; | total_size += tx_size; | ||||
} | } | ||||
if (loop_inputs) { | if (loop_inputs) { | ||||
if (!g_txindex) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
"One or more of the selected stats requires " | |||||
"-txindex enabled"); | |||||
} | |||||
Amount tx_total_in = Amount::zero(); | Amount tx_total_in = Amount::zero(); | ||||
for (const CTxIn &in : tx->vin) { | for (const CTxIn &in : tx->vin) { | ||||
CTransactionRef tx_in; | CTransactionRef tx_in; | ||||
BlockHash hashBlock; | BlockHash hashBlock; | ||||
if (!GetTransaction(in.prevout.GetTxId(), tx_in, params, | if (!GetTransaction(in.prevout.GetTxId(), tx_in, params, | ||||
hashBlock)) { | hashBlock)) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, | throw JSONRPCError(RPC_INTERNAL_ERROR, | ||||
std::string("Unexpected internal error " | std::string("Unexpected internal error " | ||||
▲ Show 20 Lines • Show All 456 Lines • Show Last 20 Lines |