Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,229 Lines • ▼ Show 20 Lines | UniValue getblockchaininfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getblockchaininfo\n" | "getblockchaininfo\n" | ||||
"Returns an object containing various state info regarding " | "Returns an object containing various state info regarding " | ||||
"blockchain processing.\n" | "blockchain processing.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"chain\": \"xxxx\", (string) current network name " | " \"chain\": \"xxxx\", (string) current network name as " | ||||
"as " | |||||
Fabien: This is still not the same layout than D2730, on which this diff is based on.
You may have… | |||||
"defined in BIP70 (main, test, regtest)\n" | "defined in BIP70 (main, test, regtest)\n" | ||||
" \"blocks\": xxxxxx, (numeric) the current number of " | " \"blocks\": xxxxxx, (numeric) the current number of " | ||||
"blocks processed in the server\n" | "blocks processed in the server\n" | ||||
" \"headers\": xxxxxx, (numeric) the current number of " | " \"headers\": xxxxxx, (numeric) the current number of " | ||||
"headers we have validated\n" | "headers we have validated\n" | ||||
" \"bestblockhash\": \"...\", (string) the hash of the " | " \"bestblockhash\": \"...\", (string) the hash of the currently " | ||||
"currently " | |||||
"best block\n" | "best block\n" | ||||
" \"difficulty\": xxxxxx, (numeric) the current " | " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" | ||||
"difficulty\n" | |||||
" \"mediantime\": xxxxxx, (numeric) median time for the " | " \"mediantime\": xxxxxx, (numeric) median time for the " | ||||
"current best block\n" | "current best block\n" | ||||
" \"verificationprogress\": xxxx, (numeric) estimate of " | " \"verificationprogress\": xxxx, (numeric) estimate of " | ||||
"verification progress [0..1]\n" | "verification progress [0..1]\n" | ||||
" \"chainwork\": \"xxxx\" (string) total amount of work " | " \"chainwork\": \"xxxx\" (string) total amount of work in " | ||||
"in " | |||||
"active chain, in hexadecimal\n" | "active chain, in hexadecimal\n" | ||||
" \"pruned\": xx, (boolean) if the blocks are " | " \"size_on_disk\": xxxxxx, (numeric) the estimated size of " | ||||
"subject " | "the block and undo files on disk\n" | ||||
" \"pruned\": xx, (boolean) if the blocks are subject " | |||||
"to pruning\n" | "to pruning\n" | ||||
" \"pruneheight\": xxxxxx, (numeric) lowest-height " | " \"pruneheight\": xxxxxx, (numeric) lowest-height complete " | ||||
"complete " | "block stored (only present if pruning is enabled)\n" | ||||
"block stored\n" | " \"automatic_pruning\": xx, (boolean) whether automatic " | ||||
"pruning is enabled (only present if pruning is enabled)\n" | |||||
" \"prune_target_size\": xxxxxx, (numeric) the target size " | |||||
"used by pruning (only present if automatic pruning is enabled)\n" | |||||
" \"softforks\": [ (array) status of softforks in " | " \"softforks\": [ (array) status of softforks in " | ||||
"progress\n" | "progress\n" | ||||
" {\n" | " {\n" | ||||
" \"id\": \"xxxx\", (string) name of softfork\n" | " \"id\": \"xxxx\", (string) name of softfork\n" | ||||
" \"version\": xx, (numeric) block version\n" | " \"version\": xx, (numeric) block version\n" | ||||
" \"reject\": { (object) progress toward " | " \"reject\": { (object) progress toward " | ||||
"rejecting pre-softfork blocks\n" | "rejecting pre-softfork blocks\n" | ||||
" \"status\": xx, (boolean) true if threshold " | " \"status\": xx, (boolean) true if threshold " | ||||
"reached\n" | "reached\n" | ||||
" },\n" | " },\n" | ||||
" }, ...\n" | " }, ...\n" | ||||
" ]\n" | " ]\n" | ||||
" \"warnings\" : \"...\", (string) any network and " | " \"warnings\" : \"...\", (string) any network and " | ||||
"blockchain warnings.\n" | "blockchain warnings.\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
Show All 9 Lines | UniValue getblockchaininfo(const Config &config, | ||||
obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); | obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); | ||||
obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()); | obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()); | ||||
obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | ||||
obj.pushKV("mediantime", int64_t(chainActive.Tip()->GetMedianTimePast())); | obj.pushKV("mediantime", int64_t(chainActive.Tip()->GetMedianTimePast())); | ||||
obj.pushKV("verificationprogress", | obj.pushKV("verificationprogress", | ||||
GuessVerificationProgress(config.GetChainParams().TxData(), | GuessVerificationProgress(config.GetChainParams().TxData(), | ||||
chainActive.Tip())); | chainActive.Tip())); | ||||
obj.pushKV("chainwork", chainActive.Tip()->nChainWork.GetHex()); | obj.pushKV("chainwork", chainActive.Tip()->nChainWork.GetHex()); | ||||
obj.pushKV("size_on_disk", CalculateCurrentUsage()); | |||||
obj.pushKV("pruned", fPruneMode); | obj.pushKV("pruned", fPruneMode); | ||||
if (fPruneMode) { | |||||
CBlockIndex *block = chainActive.Tip(); | |||||
assert(block); | |||||
while (block->pprev && (block->pprev->nStatus.hasData())) { | |||||
block = block->pprev; | |||||
} | |||||
obj.pushKV("pruneheight", block->nHeight); | |||||
// if 0, execution bypasses the whole if block. | |||||
bool automatic_pruning = (gArgs.GetArg("-prune", 0) != 1); | |||||
obj.pushKV("automatic_pruning", automatic_pruning); | |||||
if (automatic_pruning) { | |||||
obj.pushKV("prune_target_size", nPruneTarget); | |||||
} | |||||
} | |||||
const Consensus::Params &consensusParams = | const Consensus::Params &consensusParams = | ||||
config.GetChainParams().GetConsensus(); | config.GetChainParams().GetConsensus(); | ||||
CBlockIndex *tip = chainActive.Tip(); | CBlockIndex *tip = chainActive.Tip(); | ||||
UniValue softforks(UniValue::VARR); | UniValue softforks(UniValue::VARR); | ||||
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); | softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); | ||||
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); | softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); | ||||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); | softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); | ||||
softforks.push_back(SoftForkDesc("csv", 5, tip, consensusParams)); | softforks.push_back(SoftForkDesc("csv", 5, tip, consensusParams)); | ||||
obj.pushKV("softforks", softforks); | obj.pushKV("softforks", softforks); | ||||
if (fPruneMode) { | |||||
CBlockIndex *block = chainActive.Tip(); | |||||
while (block && block->pprev && block->pprev->nStatus.hasData()) { | |||||
block = block->pprev; | |||||
} | |||||
obj.pushKV("pruneheight", block->nHeight); | |||||
} | |||||
obj.pushKV("warnings", GetWarnings("statusbar")); | obj.pushKV("warnings", GetWarnings("statusbar")); | ||||
return obj; | return obj; | ||||
} | } | ||||
/** Comparison function for sorting the getchaintips heads. */ | /** Comparison function for sorting the getchaintips heads. */ | ||||
struct CompareBlocksByHeight { | struct CompareBlocksByHeight { | ||||
bool operator()(const CBlockIndex *a, const CBlockIndex *b) const { | bool operator()(const CBlockIndex *a, const CBlockIndex *b) const { | ||||
// Make sure that unequal blocks with the same height do not compare | // Make sure that unequal blocks with the same height do not compare | ||||
▲ Show 20 Lines • Show All 547 Lines • Show Last 20 Lines |
This is still not the same layout than D2730, on which this diff is based on.
You may have missed to squash some commits before rebasing.